current_app and the g Object
Access the active app and per-request storage.
Meet current_app
current_app is a proxy that always points to the app handling the work right now. Import it whenever you need the active application.
from flask import current_appWhy Not Import app?
Importing your app object directly causes circular imports as projects grow. current_app sidesteps that by resolving the app at runtime.
All lessons in this course
- App Context vs Request Context
- current_app and the g Object
- Context Locals and Thread Safety
- Push a Context in Scripts and Shells