PyScript and Flask: How to submit form and validate on Flask side | PyScript tutorial

preview_player
Показать описание
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 submit form with PyScript to Flask, how to send AJAX POST-requests with PyScript, and how to validate submitted data with Flask-WTF and FlaskForm class, and of course, save data in a database using Flask-SQLAlchemy.

When I'm clicking on the green button Pyscript sends a POST request to my Flask application, and Flask validate a user's input, and creates a City object, then it sends the object back to PyScript.

Besides that this video is about how to configure Flask instance with Application factory, how to configure CSRF protection for Flask application, how to create a custom validator for FlaskForm class.

Follow me @:

=== Links ===

Timecodes:

Flask side

00:00 - Demo, description of the project
01:21 - Description of the starting point
02:43 - Initial Flask app configuration using Flask Application factory
05:31 - Creating a database, a Flask model using SQLAlchemy. Beginning.
05:40 - Flask database configuration
07:34 - Creating a Flask model
10:08 - Creating the database with Flask-SQLAlchemy
12:03 - Creating a form (FlaskForm) to validate a user's input
13:01 - Flask custom validator
15:06 - Flask CSRF protection
16:15 - Flask handler of a POST request (using form for validation)
18:28 - Using of dataclass decorator to serialize City objects

PyScript side

19:40 - Beginning of the Pyscript, frontend part
21:56 - A form submitting description
22:33 - PyScript on click handler, and an event listener
26:44 - make_request() function definition to make AJAX POST-requests to Flask

*** Other PyScript Tutorials ***

PyScript and Flask: How to submit form and validate on Flask side | PyScript tutorial

#pyscript #django #redeyedcoderclub
Рекомендации по теме
Комментарии
Автор

What video have I make next? Any suggestions? Please write them in comments!
Follow me @:

RedEyedCoderClub
Автор

Олег, здравствуйте.
Как можно купить ваши курсы? На патреоне возможности нет, к сожалению:(

Mr.SKIFLANDIAN
Автор

this channel is best for learn pyscript 👍

koshka_sashka
Автор

hi, i just want to ask. is it possible to display the data on other page and update it when we submit the form without reload page?

rizqimultazam
Автор

Very easy to learn and understand Py Script allows you to successfully use it in writing scripts. Flexibility allows it to be integrated into other systems.

daniellewis
Автор

Great video tutorial and very informative. Thank you very much it helped me..

kostya
Автор

Great video, very helpful information, thanks.

lisw
Автор

great presentation of material and explanation. Thank you.

МаринаПеткова-ум
Автор

Thank you for the detailed and clear explanation.

Alexander-nsgn
visit shbcf.ru