Thank you, I was looking for this video since pyscript was released
@mikeckennedy2 жыл бұрын
You're most welcome! :)
@jairambala42762 жыл бұрын
What a deadly combo
@jdaniele2 жыл бұрын
Great video Michael, thanks for sharing it!
@mikeckennedy2 жыл бұрын
Thank you Daniel. :)
@elev0072 жыл бұрын
Nice explanation! Thanks Michael.
@mikeckennedy2 жыл бұрын
Glad it was helpful!
@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
@sheikhakbar20672 жыл бұрын
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!
@mikeckennedy2 жыл бұрын
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.
@alinazang66512 жыл бұрын
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.
@mikeckennedy2 жыл бұрын
I don't think one tab's webassembly has access to another does it? Do you have a link with details on that?
@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)
@moses54072 жыл бұрын
Great work! One question: why not do this without Flask?
@mikeckennedy2 жыл бұрын
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? :)
@vcool2 жыл бұрын
@@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.
@mikeckennedy2 жыл бұрын
@@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.
@maximelqt42612 жыл бұрын
Very nice! Totally unrelated question sorry, could you share how you got that button in Finder to open the terminal?
@mikeckennedy2 жыл бұрын
Thanks Maxime! That is a glorious bit of software. Get it at zipzapmac.com/Go2Shell
@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 Жыл бұрын
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 Жыл бұрын
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-sf1hp2 жыл бұрын
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.
@mikeckennedy2 жыл бұрын
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-man27548 ай бұрын
I don't understand. it didn't work for at all its like html didn't recognize it ....help me.
@Lugoxc6 ай бұрын
Thanks for the tutorial. is this possible with nicegui?
@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 Жыл бұрын
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 Жыл бұрын
Hi Michael, How I can convert python file into .wasm binary?
@funguy29 Жыл бұрын
Is Blazor WASM more performant than this ?
@user-wo5lq1vx7r Жыл бұрын
How we can use opencv in pyscript?
@mayorca_institute2 жыл бұрын
Please do it again.... I need a clearer view
@kenspicer2632 жыл бұрын
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?
@mikeckennedy2 жыл бұрын
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.
@RealEstate3D2 жыл бұрын
Is there any advantage to just using JavaScript? In which situation one should prefer python?
@anangayman15092 жыл бұрын
JS is way faster since python is an interpreted language. BUT IMO, python is way easier to learn and its more intuitive
@slamdunklabs Жыл бұрын
when you need python modules. I think it is data science / math domain
@baby121732 жыл бұрын
Hey can pyscript use the DOM. Also can develop a website with pyscript
@mikeckennedy2 жыл бұрын
Yep! There is even a chapter in the video exactly about that: 14:58 DOM manipulation and driving the UI with client-side Python
@darkModeYT2 жыл бұрын
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
@mikeckennedy2 жыл бұрын
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.
@GameCrawl2 жыл бұрын
Is this full stack in a way?
@mikeckennedy2 жыл бұрын
Ha, it is in a sense.
@mtmow2 жыл бұрын
Can pyscript work with other browser apis?
@mikeckennedy2 жыл бұрын
Yeah, I think it has full interop between JavaScript, so it should be able to be used at least in that style.
@mtmow2 жыл бұрын
@@mikeckennedy Typescript already won me, but i don't see harm in trying this out for fun, thanks