forked from plotly/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_apps.py
74 lines (67 loc) · 1.69 KB
/
test_apps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from multiprocessing import Value
from dash.exceptions import PreventUpdate
from werkzeug.exceptions import HTTPException
import numpy as np
import functools
import quart
import operator
import json
import dash
from dash import (
Dash,
Input,
Output,
State,
html,
dcc,
dash_table,
no_update,
callback_context,
set_props
)
import pytest
import dash
from dash import Dash, Input, State, dcc, html, Output
from dash.dash import _ID_LOCATION
from dash.exceptions import NoLayoutException
def get_routing_inputs_app():
app = Dash(
__name__,
use_pages=True,
routing_callback_inputs={
"hash": State(_ID_LOCATION, "hash"),
"language": Input("language", "value"),
},
)
# Page with layout from a variable: should render and not be impacted
# by routing callback inputs
dash.register_page(
"home",
layout=html.Div("Home", id="contents"),
path="/",
)
# Page with a layout function, should see the routing callback inputs
# as keyword arguments
def layout1(hash: str = None, language: str = "en", **kwargs):
translations = {
"en": "Hash says: {}",
"fr": "Le hash dit: {}",
}
return html.Div(translations[language].format(hash), id="contents")
dash.register_page(
"function_layout",
path="/function-layout",
layout=layout1,
)
app.layout = html.Div(
[
dcc.Dropdown(id="language", options=["en", "fr"], value="en"),
dash.page_container,
]
)
return app
app = get_routing_inputs_app()
if __name__ == "__main__":
app.run(
debug=True,
)