-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Flask Web and API Development
By :

In Chapter 1, the CRUD operations of every view function became possible without an ORM because of a custom decorator, @connect_db
. The decorator was responsible for database connectivity and closure for every execution of the view function. Like in any Python decorator, the @connect_db
executes first before the view function starts receiving the requests from the client and executes after the view generates the response.
On the other hand, Chapter 2 introduced the use of @before_request
and @after_request
decorators in managing the application context of the view functions. Our applications used them to access the session db
object for SQLAlchemy’s database connectivity, impose user authentication, and perform software logging.
Using decorators to manage the requests and responses for a view or API function is called route filtering. The following are implementations of Flask’s before_request
and after_request
methods used by...