Book Image

Flask Framework Cookbook

By : Shalabh Aggarwal
Book Image

Flask Framework Cookbook

By: Shalabh Aggarwal

Overview of this book

Table of Contents (19 chapters)
Flask Framework Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Working with Views

For any web application, it is very important to control how you interact with web requests and the proper responses to be catered for these requests. This chapter takes us through the various methods of handling the requests properly and designing them in the best way.

In this chapter, we will cover the following recipes:

  • Writing function-based views and URL routes

  • Class-based views

  • URL routing and product-based pagination

  • Rendering to templates

  • Dealing with XHR requests

  • Decorator to handle requests beautifully

  • Creating custom 404 and 500 handlers

  • Flashing messages for better user feedback

  • SQL-based searching