I wrote two blog posts on TestDriven.io about how the Application and Request contexts are handled in Flask:
- Basics: Understanding the Application and Request Contexts in Flask
- Advanced: Deep Dive into Flask’s Application and Request Contexts
The first blog post provides examples of how to the Application and Request contexts work, including how the current_app
, request
, test_client
, and test_request_context
can be used to effectively used to avoid pitfalls with these contexts.
The second blog post provides a series of diagrams illustrating how the Application and Request contexts are processed when a request is handled in Flask. This post also dives into how LocalStack
objects work, which are the objects used for the Application Context Stack and the Request Context Stack.
from Planet Python
via read more
No comments:
Post a Comment