MCPcopy
hub / github.com/plotly/dash / get_app

Function get_app

dash/_get_app.py:44–71  ·  view source on GitHub ↗

Return the current Dash app instance. Useful in multi-page apps when Python files within the `pages/` folder need to reference the `app` object but importing it directly would cause a circular import error.

()

Source from the content-addressed store, hash-verified

42
43
44def get_app():
45 """
46 Return the current Dash app instance.
47
48 Useful in multi-page apps when Python files within the `pages/` folder
49 need to reference the `app` object but importing it directly would cause
50 a circular import error.
51 """
52 try:
53 ctx_app = app_context.get()
54 if ctx_app is not None:
55 return ctx_app
56 except LookupError:
57 pass
58
59 if APP is None:
60 raise AppNotFoundError(
61 dedent(
62 """
63 App object is not yet defined. `app = dash.Dash()` needs to be run
64 before `dash.get_app()`.
65
66 `dash.get_app()` is used to get around circular import issues when Python files
67 within the pages/` folder need to reference the `app` object.
68 """
69 )
70 )
71 return APP

Callers 15

_get_callback_managerFunction · 0.90
add_contextFunction · 0.90
async_add_contextFunction · 0.90
validate_use_pagesFunction · 0.90
traverseFunction · 0.90
find_componentFunction · 0.90
record_timingMethod · 0.90
timing_informationMethod · 0.90
websocketMethod · 0.90

Calls 2

AppNotFoundErrorClass · 0.90
getMethod · 0.45

Tested by 3

layout_hookFunction · 0.72
error_hookFunction · 0.72
callback_hookFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…