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

Introduction

Flask offers several ways of designing and laying out the URL routing for our applications. Also, it gives ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.