PyScript and Flask: Basic PyScript Frontend and DOM manipulations | PyScript tutorial

  Рет қаралды 7,718

Red Eyed Coder Club

Red Eyed Coder Club

Күн бұрын

This is a very simple project built with PyScript and Flask.
Flask on the backend side, and Pyscript as the frontend.
The main idea of the video is to show how to use only Python both for backend and frontend.
I wanted to show how to make AJAX (asynchronous) GET and POST requests with Pyscript to Flask application, and how to manipulate DOM with Pyscript.
The frontend of the project is written with PyScript. When i'm clicking on the red button ... PyScript sends a GET request to my Flask application and gets a random number from 1 to 10...
When I click on a card... Pyscript sends a POST request to the Flask app and gets the float version of the sent numbers.
And again the video is about how to use Pyscript to send GET and POST requests to Flask, and how use Pyscript to manipulate with DOM
Follow me @:
Telegram: t.me/red_eyed_coder_club
Twitter: / codereyed
Facebook: redeyedcoderclub
=== 📎 The source code is available via Patreon ===
/ 68004918
Timecodes:
00:00 - Description of the Pyscript Flask project, attaching Python module to HTML template.
03:01 - Pyscript basic example.
03:40 - Basic Pyscript on-click event handler and event listener.
06:41 - Creating a basic function to send GET requests from Pyscript to Flask
08:40 - Using of pyfetch to send requests to Flask
10:13 - Creating a Pyscript event handler for a button. Pyscript DOM manipulations.
13:41 - The Flask side: handling requests from Pyscript
16:59 - How to send a POST request with Pyscript to Flask.
24:13 - Result of using Pyscript on Flask frontend.
** Other Flask Tutorials **
Flask AJAX Tutorial: Basic AJAX in Flask app: • Flask AJAX Tutorial: B...
Python Flask and Vue Tutorial: • Python Flask Vue Tutor...
Flask tutorial - blog project: • Python Flask Tutorial ...
Pyscript and Flask: Basic Pyscript Frontend and DOM manipulations | Pyscript tutorial
• PyScript and Flask: Ba...
#pyscript #flask #redeyedcoderclub

Пікірлер: 88
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
What video should I make next? Any suggestions? Follow me @: Telegram: t.me/red_eyed_coder_club Twitter: twitter.com/CoderEyed Facebook: fb.me/redeyedcoderclub Timecodes: 00:00 - Description of the Pyscript Flask project, attaching Python module to HTML template. 03:01 - Pyscript basic example. 03:40 - Basic Pyscript on-click event handler and event listener. 06:41 - Creating a basic function to send GET requests from Pyscript to Flask 08:40 - Using of pyfetch to send requests to Flask 10:13 - Creating a Pyscript event handler for a button. Pyscript DOM manipulations. 13:41 - The Flask side: handling requests from Pyscript 16:59 - How to send a POST request with Pyscript to Flask. 24:13 - Result of using Pyscript on Flask frontend. Help to promote the channel. Please, like, share and subscribe!
@j1351209
@j1351209 2 жыл бұрын
pyscript and django...pyscript and fastapi
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
@@j1351209 Thank you for you suggestions. I'll make them a bit latter.
@zoiapelevina3539
@zoiapelevina3539 2 жыл бұрын
This is exactly the information I needed. Thank you.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you
@user-yv2zg6hw3k
@user-yv2zg6hw3k 2 жыл бұрын
Excellent. Everything is described in detail.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you
@innochka9107
@innochka9107 2 жыл бұрын
Thank you for the detailed explanation.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks a lot!
@kostya9169
@kostya9169 2 жыл бұрын
Thank you very much for the interesting and informative video.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@user-fw4od8cg5s
@user-fw4od8cg5s 2 жыл бұрын
Excellent and very useful lessons on your website. Thank you so much for your efforts!
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@vadimsamoilov9452
@vadimsamoilov9452 2 жыл бұрын
It was really interesting, for me personally. Thank you.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@user-kv1dd9yv8c
@user-kv1dd9yv8c 2 жыл бұрын
Great video lesson. Everything is clearly explained.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@annaaniytkina5963
@annaaniytkina5963 2 жыл бұрын
This is something new for me. Thank you.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you
@olenkafomina9471
@olenkafomina9471 2 жыл бұрын
quite detailed and understandable. The author of the video is well done.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@user-uq4wt4gz6e
@user-uq4wt4gz6e 2 жыл бұрын
Video is great!
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@rangabharath4253
@rangabharath4253 2 жыл бұрын
Awesome Python for both frontend and backend 🎉🥳👌
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Yep. Under the hood PyScript translates Python code to JavaScript code. But yeah... we can use Python on frontend.
@TdadadT9
@TdadadT9 2 жыл бұрын
​@@RedEyedCoderClub are you sure? I read that python compiles directly to webassembly instead of JS. And only some parts of python code translates into js But we still have no native support of python :( Anyway, its a big step for python
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
My bad, and you are right. PyScript is running with a WebAssembly build of CPython. PyScript doesn't translate Python code to JavaScript. I was confused with this description: pyodide.org/en/stable/ "Pyodide comes with a robust Javascript ⟺ Python foreign function interface so that you can freely mix these two languages in your code with minimal friction. This includes full support for error handling (throw an error in one language, catch it in the other), async/await, and much more."
@Candy-qe3nd
@Candy-qe3nd 2 жыл бұрын
Thank you for showing me how to use Python on this project.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@annadornt6442
@annadornt6442 2 жыл бұрын
It was interesting, and most importantly, useful.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@dariafrimen4816
@dariafrimen4816 2 жыл бұрын
Video is great! It was interesting.👍👍👍
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@OlegBosi
@OlegBosi 2 жыл бұрын
very good!!1
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@chdddhfffgfgf1782
@chdddhfffgfgf1782 2 жыл бұрын
Good video, I went to learn Python thanks for the video and for motivation)
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Glad to help :) Good luck!
@andreylagno2372
@andreylagno2372 2 жыл бұрын
very good video
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you
@user-yg6pm4yi5d
@user-yg6pm4yi5d 2 жыл бұрын
exellent video
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@nadijalesina6864
@nadijalesina6864 2 жыл бұрын
We learn any programming language from the basics and Basic Script is no exception. And then we replenish our knowledge and develop our capabilities. And they are limitless, believe me.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
mmm... ok... thanks for comment, and have a nice day
@jackbarlow5431
@jackbarlow5431 2 жыл бұрын
Python is really very easy to use, and its objects and methods allow you to create a very diverse application in practice, with a good interface and high-quality functionality.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thanks for comment
@evalinor
@evalinor 2 жыл бұрын
Oleg, thank you. maybe after few year we will see framework based on pyscript + flask, fastapi, drf etc.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
It's my dream :) To use only one language for all.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Didn't find your last comment, but the minimal example with setInterval can be the following: import js from pyodide import create_proxy counter = 0 def interval(): global counter counter += 1 document.getElementById("msg").innerHTML = "Counter = " + str(counter) proxy = create_proxy(interval) js.setInterval(proxy, 1000) and the .setInterval() returns an id, that can be used to clear interval wit js.clearInterval(id)
@gulrukh1386
@gulrukh1386 3 ай бұрын
hi there, In document.getElementById('left'), document is red underlined, how to correct it, which library is required to import document. thanks
@abrikosa717
@abrikosa717 2 жыл бұрын
Thank you very much for the video. I'm wondering will the PyScript replace JavaScript or at least will compete with it.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you! Yep, time will show :D
@fuu9818
@fuu9818 Жыл бұрын
It's biggest (or its only challenge in regards to python coders) is speed and scalability
@erjiaxiao6577
@erjiaxiao6577 2 жыл бұрын
could i ask why we need await in front of pyfetch()? there is no task loop for async in the code, so does await make no sense here?
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
The fetch() function that works under the hood is an asynchronous function, and so we have to use async/await syntax. The event loop is also used under the hood.
@erjiaxiao6577
@erjiaxiao6577 2 жыл бұрын
@@RedEyedCoderClubok i see. thanks a lot! it really help!
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Glad that helped. Feel free to ask me anything. If I know I'll answer.
@lecrowpus.
@lecrowpus. Жыл бұрын
Pyscript + Flask =Holy Shit!!💩
@RedEyedCoderClub
@RedEyedCoderClub Жыл бұрын
It's just an experimental technology
@TdadadT9
@TdadadT9 2 жыл бұрын
Oleg, Im watching you from the scratch of 2016 and today I understand that the way when you'r writing code and explaining details simultaneously seems too complicated for comprehansion. I recommend you to spend less time on writing code online and instead concentrate more on explaining details because that is the thing where you have no competitiors :) Its just an advice, so dont consider it as a negative comment or just something like this. Keep it up anyway =)
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you for your suggestions. I do this, because I always thought that explaining the already written code is a bad way to transfer the comprehension.
@deymonster2u
@deymonster2u 2 жыл бұрын
great theme about pyscript! It seems to me that your voice sounds similar to Oleg Molchanov? Are you Oleg? I saw your old videos about Flask
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you! Yep, it's me
@ibrahimoglu
@ibrahimoglu 2 жыл бұрын
👍
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
@ibrahimoglu
@ibrahimoglu 2 жыл бұрын
@@RedEyedCoderClub Ben teşekkür ederim.
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Have a nice day :)
@shinhaewon
@shinhaewon Жыл бұрын
how can i use pyfetch that have json body with 'POST' method ?
@RedEyedCoderClub
@RedEyedCoderClub Жыл бұрын
The answer on your question is in this video. If you would like to post some form with PyScript, consider watching this video: kzbin.info/www/bejne/mqibhoCwn7qUisk
@shinhaewon
@shinhaewon Жыл бұрын
@@RedEyedCoderClub thank you
@shinhaewon
@shinhaewon Жыл бұрын
@@RedEyedCoderClub pyfetch's parameter 'url' works in 'py-script' tag, but it doesn't work in file
@RedEyedCoderClub
@RedEyedCoderClub Жыл бұрын
check you code please. It works in the file.
@shinhaewon
@shinhaewon Жыл бұрын
​@@RedEyedCoderClub I decided url /decode but program posts index page
@Just_Saidd
@Just_Saidd 2 жыл бұрын
If the Pyscript will get popularity in production then a python developer will get more money ))
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
So true! Thanks for comment btw!
@sashapomin
@sashapomin 2 жыл бұрын
I always search an easy money
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
I'm too... thanks for comment anyway
@user-fc9gq1on1w
@user-fc9gq1on1w 2 жыл бұрын
Video is great! It was interesting.👍👍👍
@RedEyedCoderClub
@RedEyedCoderClub 2 жыл бұрын
Thank you!
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 36 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 3,3 МЛН
PINK STEERING STEERING CAR
00:31
Levsob
Рет қаралды 24 МЛН
small vs big hoop #tiktok
00:12
Анастасия Тарасова
Рет қаралды 19 МЛН
Flask AJAX Tutorial: Basic AJAX in Flask app | Flask casts
18:31
Red Eyed Coder Club
Рет қаралды 18 М.
Pyscript: Python In The Browser!
9:19
Jake Callahan
Рет қаралды 1,6 М.
PyScript is officially here!🚀 Build web apps with Python & HTML
17:10
Run Python Script Clicking Html Button | Latest 2021
17:22
Bytive
Рет қаралды 130 М.
Flask Blueprints Make Your Apps Modular & Professional
13:33
NeuralNine
Рет қаралды 34 М.
PyScript Demo / Tutorial | End-to-end PyScript Tutorial #1
28:01
Samuel Chan
Рет қаралды 37 М.
The Truth about Rust/WebAssembly Performance
29:47
Greg Johnston
Рет қаралды 173 М.
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 36 МЛН