flâneur — a map of the web's best reading

The Application Context — Flask Documentation (2.3.x)

flask.palletsprojects.com · 803 words · saved by 1 readers

The application context keeps track of the application-level data during a request, CLI command, or other activity. Rather than passing the application around to each function, the current_app and g proxies are accessed instead. This is similar to The Request Context, which keeps track of request-level data during a request. A corresponding application context is pushed when a request context is pushed. The Flask application object has attributes, such as config, that are useful to access within views and CLI commands. However, importing the app instance within the modules in your project is prone to circular import issues. When using the app factory pattern or writing reusable blueprints or extensions there won’t be an app instance to import at all. Flask solves this issue with the application context. Rather than referring to an app directly, you use the current_app proxy, which points to the application handling the current activity. Flask automatically pushes an application context

The Application Context — Flask Documentation (3.1.x) Navigation index modules | next | previous | Flask Documentation (3.1.x) » The Application Context The Application Context ¶ The application context keeps track of the application-level data during a request, CLI command, or other activity. Rather than passing the application around to each function, the current_app and g proxies are accessed instead. This is similar to The Request Context , which keeps track of request-level data during a request. A corresponding application context is pushed when a request context is pushed. Pu

Explore this link on the map →

related reading