No video

Python + pyscript + WebAssembly: Python Web Apps, Running Locally with pyscript

  Рет қаралды 46,208

Michael Kennedy

Michael Kennedy

Күн бұрын

Пікірлер: 47
@riadibadulla
@riadibadulla 2 жыл бұрын
Thank you, I was looking for this video since pyscript was released
@mikeckennedy
@mikeckennedy 2 жыл бұрын
You're most welcome! :)
@jairambala4276
@jairambala4276 2 жыл бұрын
What a deadly combo
@jdaniele
@jdaniele 2 жыл бұрын
Great video Michael, thanks for sharing it!
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Thank you Daniel. :)
@elev007
@elev007 2 жыл бұрын
Nice explanation! Thanks Michael.
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Glad it was helpful!
@alxizr
@alxizr Жыл бұрын
Hi mike, great video. Thanks very much. Can we make it work in react for example ? My concern is the DOM interactions. If i want to add a callback to an element. Pyscript requires grabbing it from the DOM with query selector and id which is something that is a big no no in react
@sheikhakbar2067
@sheikhakbar2067 2 жыл бұрын
Pyscript arrived just in time when I gave up on learning JS ... Seriously I can't think of anything I can do with JS except run my python code in the browser... I can't wait for Pyscript to become fully functional! What I really want to build with pyscript; is a simple Quiz app ..... It's a fill-in-the-blank quiz .. it should be case insensitive; Normal python would do that in a couple of lines; assuming .. the questions and answers are stored in a simple pandas dataframe!
@mikeckennedy
@mikeckennedy 2 жыл бұрын
It should be pretty possible with pyscript. I do think it has some maturing before it’s ready for prime time. But this little app does show what might be possible soon.
@alinazang6651
@alinazang6651 2 жыл бұрын
One big advantage of Webassembly is that it runs in its own process separate from browser's page. I can see this as a performant way to listen to DOM changes on other people's websites (thru Mutationobserver), and with python - as a convenient way to do complex logic on it or integrate some unique python libraries to enhance functionality of web pages.
@mikeckennedy
@mikeckennedy 2 жыл бұрын
I don't think one tab's webassembly has access to another does it? Do you have a link with details on that?
@dhkatz_
@dhkatz_ 2 жыл бұрын
You can't access other sites unless they're on the same domain and were created within the existing tab (like with window.open)
@moses5407
@moses5407 2 жыл бұрын
Great work! One question: why not do this without Flask?
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Hey Jim. Because I really wanted to show how to use pyscript with a JSON API. My experience using public free APIs is that they are fine for awhile then either go offline, change their schema in a breaking way, etc. Using Flask (or any dynamic server app) let's me ship something to people as part of the project to demo how to client/server comms without worrying about it only working for 6 months. But if you had another API already running somewhere, it's definitely not needed, right? :)
@vcool
@vcool 2 жыл бұрын
@@mikeckennedy Using Flask here is missing the point altogether. If you control the server runtime, you don't need pyscript. Pyscript is for when you want to use static hosting.
@mikeckennedy
@mikeckennedy 2 жыл бұрын
@@vcool What? It doesn't miss the point *at all*. Here is the point. I want to create a client-side pyscript app. I want that app to consume an API. I want that API to be stable. Hence, I shipped the app with a stable API in the form of the Flask app. In a "real" version, it would point at openweathermap.org or something like that. But this requires people playing with the app to register, create an account, enter API keys, etc. etc. That's useless, so why don't I make that simple. In a real app, you would use a real API like this. But in a demo app on a KZfaq video that cannot be edited or changed even if the API changes, you might choose something simpler.
@maximelqt4261
@maximelqt4261 2 жыл бұрын
Very nice! Totally unrelated question sorry, could you share how you got that button in Finder to open the terminal?
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Thanks Maxime! That is a glorious bit of software. Get it at zipzapmac.com/Go2Shell
@ComputerVisionEngineer
@ComputerVisionEngineer Жыл бұрын
Hey Michael, nice tutorial, do you know if there is a way of getting frames from the webcam using pyscript? Using opencv and calling cv2.VideoCapture(0) as I usually do in Python doesn't seem to work. I am surprised I haven't been able to find any documentation on how to do it.
@mikeckennedy
@mikeckennedy Жыл бұрын
Thanks! It's likely possible. There is deep integration with JavaScript and PyScript. And JavaScript can do webcam stuff. So I'd see how to do it in JavaScript and then tie it in there.
@aadityakotadia5280
@aadityakotadia5280 Жыл бұрын
Hi! I was making a personal project using openCV (and mediapipe) and had the same question. Did you ever figure out what to do? Thanks!
@MuhammadAhmad-sf1hp
@MuhammadAhmad-sf1hp 2 жыл бұрын
What was the icon you clicked in the finder to create a virtual environment in mac os? ... There should be a way to use py-script for server-side rendering, just like the svelte kit, which takes a ton of load from the browser and instantly deliver the content.
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Hey. I clicked my Go2Shell button (an add on) in Finder. But then just ran a virtual environment command like any other after it opened. As for running server-side, interesting yes. But AFAIK not something they are working on.
@sammyay-man2754
@sammyay-man2754 8 ай бұрын
I don't understand. it didn't work for at all its like html didn't recognize it ....help me.
@Lugoxc
@Lugoxc 6 ай бұрын
Thanks for the tutorial. is this possible with nicegui?
@ThrillDaWill
@ThrillDaWill Жыл бұрын
I’ve been trying to figure out how to install modules and add them to my website projects that can be used and referenced by pyscript but I haven’t found a solution. Is there anyway I could reference these custom modules for my web application? Any help would be much appreciated!
@flakeybran1447
@flakeybran1447 Жыл бұрын
I’m still an amateur at programming and IT, but what about storing the modules on a server and requesting them as needed from the program? I’m assuming the request module would function just fine considering it comes with the python installation.
@pranjalsrivastava2462
@pranjalsrivastava2462 Жыл бұрын
Hi Michael, How I can convert python file into .wasm binary?
@funguy29
@funguy29 Жыл бұрын
Is Blazor WASM more performant than this ?
@user-wo5lq1vx7r
@user-wo5lq1vx7r Жыл бұрын
How we can use opencv in pyscript?
@mayorca_institute
@mayorca_institute 2 жыл бұрын
Please do it again.... I need a clearer view
@kenspicer263
@kenspicer263 2 жыл бұрын
Does pyscript require python3.10 . I've been trying to point to a third party app installed locally on my machine using the 'paths' directive in the html code but pyscript seems to ignore it. Do you know how this should work?
@mikeckennedy
@mikeckennedy 2 жыл бұрын
No, it runs out of the browser. To use a library, you have to link to the 2heel on the internet or your static files folder.
@RealEstate3D
@RealEstate3D 2 жыл бұрын
Is there any advantage to just using JavaScript? In which situation one should prefer python?
@anangayman1509
@anangayman1509 2 жыл бұрын
JS is way faster since python is an interpreted language. BUT IMO, python is way easier to learn and its more intuitive
@slamdunklabs
@slamdunklabs Жыл бұрын
when you need python modules. I think it is data science / math domain
@baby12173
@baby12173 2 жыл бұрын
Hey can pyscript use the DOM. Also can develop a website with pyscript
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Yep! There is even a chapter in the video exactly about that: 14:58 DOM manipulation and driving the UI with client-side Python
@darkModeYT
@darkModeYT 2 жыл бұрын
QUESTION First of all, thank you for your awesome tutorial! I have a question how to make at least some functions work offline. Otherwise I don't get why to download compiled Web Assebly and python wheels if I can't use them without connection to the server
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Thanks! In a more full-featured app, you would sync the remote data to local storage then process that data and show it with pyscript if you're offline and use the api when you are online. But that wasn't the point of this video so I didn't make it that complex.
@GameCrawl
@GameCrawl 2 жыл бұрын
Is this full stack in a way?
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Ha, it is in a sense.
@mtmow
@mtmow 2 жыл бұрын
Can pyscript work with other browser apis?
@mikeckennedy
@mikeckennedy 2 жыл бұрын
Yeah, I think it has full interop between JavaScript, so it should be able to be used at least in that style.
@mtmow
@mtmow 2 жыл бұрын
@@mikeckennedy Typescript already won me, but i don't see harm in trying this out for fun, thanks
An introduction to WebAssembly
25:23
Coding Tech
Рет қаралды 188 М.
PyScript is officially here!🚀 Build web apps with Python & HTML
17:10
Советы на всё лето 4 @postworkllc
00:23
История одного вокалиста
Рет қаралды 5 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 36 МЛН
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 158 МЛН
Chris Laffra - PyScript - Python in the browser
33:01
PyData
Рет қаралды 1,9 М.
"What can't WebAssembly do?" - Katie Bell (PyCon AU 2023)
29:03
Python GC Settings - Change This and Go 20% Faster!
14:14
Michael Kennedy
Рет қаралды 5 М.
100+ Web Development Things you Should Know
13:18
Fireship
Рет қаралды 1,4 МЛН
PyScript is Python in Your Browser
15:09
NeuralNine
Рет қаралды 23 М.
Советы на всё лето 4 @postworkllc
00:23
История одного вокалиста
Рет қаралды 5 МЛН