September 2015
Intermediate to advanced
288 pages
5h 30m
English
The final piece of the Model View Controller (MVC) equation is controllers. We have already seen the basic usage of the view functions in our main.py file. Now, the more complex and powerful versions will be introduced, and we will turn our disparate view functions in cohesive wholes. We will also discuss the internals of how Flask handles the lifetime of an HTTP request and advanced ways to define Flask views.
In some cases, a request-specific variable is needed across all view functions and needs to be accessed from the template as well. To achieve this, we can use Flask's decorator function @app.before_request and the object g. The function @app.before_request ...