load_app() — flask Function Reference
Architecture documentation for the load_app() function in cli.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 6cabef6b_f1ce_76af_5916_c4e9a439548c["load_app()"] 9fb0ba66_32bf_1412_77b1_174dae79c4b2["ScriptInfo"] 6cabef6b_f1ce_76af_5916_c4e9a439548c -->|defined in| 9fb0ba66_32bf_1412_77b1_174dae79c4b2 7a19d77a_86f4_0e30_0626_5cb2e17c7eae["with_appcontext()"] 7a19d77a_86f4_0e30_0626_5cb2e17c7eae -->|calls| 6cabef6b_f1ce_76af_5916_c4e9a439548c 596bd738_9f64_52c9_9cdc_d6c4ce8f6278["get_command()"] 596bd738_9f64_52c9_9cdc_d6c4ce8f6278 -->|calls| 6cabef6b_f1ce_76af_5916_c4e9a439548c d828f6fc_89be_5a05_5589_42611ae7786a["list_commands()"] d828f6fc_89be_5a05_5589_42611ae7786a -->|calls| 6cabef6b_f1ce_76af_5916_c4e9a439548c 112697fd_abe3_7738_1bc4_8f3d27bbbb68["run_command()"] 112697fd_abe3_7738_1bc4_8f3d27bbbb68 -->|calls| 6cabef6b_f1ce_76af_5916_c4e9a439548c d374b506_8b36_b4e6_3147_5db4fa8f8d91["app()"] 6cabef6b_f1ce_76af_5916_c4e9a439548c -->|calls| d374b506_8b36_b4e6_3147_5db4fa8f8d91 d3588a10_397e_57ef_4714_4c8c478b107b["prepare_import()"] 6cabef6b_f1ce_76af_5916_c4e9a439548c -->|calls| d3588a10_397e_57ef_4714_4c8c478b107b 95e11cb3_caab_ad8f_3f8c_c26632862fe3["locate_app()"] 6cabef6b_f1ce_76af_5916_c4e9a439548c -->|calls| 95e11cb3_caab_ad8f_3f8c_c26632862fe3 aa03072d_fb08_de41_1ce0_535b2a2f9d00["get_debug_flag()"] 6cabef6b_f1ce_76af_5916_c4e9a439548c -->|calls| aa03072d_fb08_de41_1ce0_535b2a2f9d00 style 6cabef6b_f1ce_76af_5916_c4e9a439548c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/cli.py lines 333–372
def load_app(self) -> Flask:
"""Loads the Flask app (if not yet loaded) and returns it. Calling
this multiple times will just result in the already loaded app to
be returned.
"""
if self._loaded_app is not None:
return self._loaded_app
app: Flask | None = None
if self.create_app is not None:
app = self.create_app()
else:
if self.app_import_path:
path, name = (
re.split(r":(?![\\/])", self.app_import_path, maxsplit=1) + [None]
)[:2]
import_name = prepare_import(path)
app = locate_app(import_name, name)
else:
for path in ("wsgi.py", "app.py"):
import_name = prepare_import(path)
app = locate_app(import_name, None, raise_if_not_found=False)
if app is not None:
break
if app is None:
raise NoAppException(
"Could not locate a Flask application. Use the"
" 'flask --app' option, 'FLASK_APP' environment"
" variable, or a 'wsgi.py' or 'app.py' file in the"
" current directory."
)
if self.set_debug_flag:
# Update the app's debug flag through the descriptor so that
# other values repopulate as well.
app.debug = get_debug_flag()
self._loaded_app = app
return app
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does load_app() do?
load_app() is a function in the flask codebase, defined in src/flask/cli.py.
Where is load_app() defined?
load_app() is defined in src/flask/cli.py at line 333.
What does load_app() call?
load_app() calls 4 function(s): app, get_debug_flag, locate_app, prepare_import.
What calls load_app()?
load_app() is called by 4 function(s): get_command, list_commands, run_command, with_appcontext.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free