0PricingLogin
Flask Academy · Lesson

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_app

Why 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

  1. App Context vs Request Context
  2. current_app and the g Object
  3. Context Locals and Thread Safety
  4. Push a Context in Scripts and Shells
← Back to Flask Academy