Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Building Web Applications with Flask
  • Table Of Contents Toc
Building Web Applications with Flask

Building Web Applications with Flask

By : Italo Maia
4 (1)
close
close
Building Web Applications with Flask

Building Web Applications with Flask

4 (1)
By: Italo Maia

Overview of this book

If you are a Python web developer who wants to learn more about developing applications in Flask and scaling them with industry-standard practices, this is the book for you.
Table of Contents (12 chapters)
close
close
11
Index

Beyond GET


So far we've had a few cozy examples with Ajax and RESTful Web services but we have yet to record data in our database using a service. How about trying that now?

Recording to the database using Web services is not much different from what we have done in the previous chapter. We'll receive data from an Ajax request, we will check which HTTP method was used in order to decide what to do, then we'll validate the sent data and save everything if no error was found. In Chapter 4, Please Fill in This Form, Madam, we talked about CSRF protection and its importance. We'll keep validating our data against CSRF with our Web service. The trick is to add the CSRF token to the form data being submitted. See the attached code provided with the eBook for the example HTML.

This is how our view looks like with POST, PUT, and REMOVE method support:

@app.route("/articles/", methods=["GET", "POST"])
@app.route("/articles/<int:article_id>", methods=["GET", "PUT", "DELETE"])
def articles(article_id...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Building Web Applications with Flask
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon