app_context() — flask Function Reference
Architecture documentation for the app_context() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 92f86b9d_3382_d2d4_7d8f_03f683ac426b["app_context()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 92f86b9d_3382_d2d4_7d8f_03f683ac426b -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 7a19d77a_86f4_0e30_0626_5cb2e17c7eae["with_appcontext()"] 7a19d77a_86f4_0e30_0626_5cb2e17c7eae -->|calls| 92f86b9d_3382_d2d4_7d8f_03f683ac426b 596bd738_9f64_52c9_9cdc_d6c4ce8f6278["get_command()"] 596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| 92f86b9d_3382_d2d4_7d8f_03f683ac426b style 92f86b9d_3382_d2d4_7d8f_03f683ac426b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 1462–1480
def app_context(self) -> AppContext:
"""Create an :class:`.AppContext`. When the context is pushed,
:data:`.current_app` and :data:`.g` become available.
A context is automatically pushed when handling each request, and when
running any ``flask`` CLI command. Use this as a ``with`` block to
manually push a context outside of those situations, such as during
setup or testing.
.. code-block:: python
with app.app_context():
init_db()
See :doc:`/appcontext`.
.. versionadded:: 0.9
"""
return AppContext(self)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does app_context() do?
app_context() is a function in the flask codebase, defined in src/flask/app.py.
Where is app_context() defined?
app_context() is defined in src/flask/app.py at line 1462.
What calls app_context()?
app_context() is called by 2 function(s): get_command, with_appcontext.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free