Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Course conclusion
Login or purchase this course to watch this video and the rest of the course contents.
0:00 The next important idea that we talked about was HTML forms accepting user input. Switching between different view methods based on the HTTP verb
0:10 like one for GET and one for POST and all of that really evolved around this get/post/redirect pattern or post/get/redirect if you believe Wikipedia.
0:19 And the idea was that we're going to go and do a GET a user with their web browser and their laptop here is going to do a get for accounts/register.
0:27 The servers are going to respond with just that form probably not filled out at all. Then they fill that out
0:33 with my first name's this, my last name's that my email I'm going to use this such and such and so on
0:37 and then they press save or create account or whatever and it does a post back to the same URL. It's a different view method.
0:44 We're going to save that validated data to the database and if we're all happy then we're going to send them a redirect to some page.
0:50 Like redirect to welcome or redirect to slash account or whatever it is they're signing in for. And this avoids that weird error
0:57 where if you try to refresh a page it says warning you're going to resubmit it. It just makes everything super nice and clear
1:03 and this definitely a pattern you want to apply. It's really easy with Flask and the decorators to distinguish between the different steps
1:10 with different methods just using the methods part of the decorator in blueprint.route or app.route.