-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.py
92 lines (80 loc) · 2.56 KB
/
index.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
Index
=====
"""
import dash
from dash.dependencies import Input, Output
from dash.dcc import Link, Location, Markdown
from dash.html import A, Div, H3, P
import apps.rgb_colourspace_transformation_matrix as app_1
import apps.rgb_colourspace_chromatically_adapted_primaries as app_2
from app import APP, SERVER # noqa: F401
__author__ = "Colour Developers"
__copyright__ = "Copyright 2018 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "Colour Developers"
__email__ = "[email protected]"
__status__ = "Production"
__all__ = ["load_app"]
APP.layout = Div([Location(id="url", refresh=False), Div(id="apps")])
@APP.callback(Output("apps", "children"), [Input("url", "pathname")])
def load_app(app: dash.Dash):
"""
Load given app into the appropriate :class:`Div` class instance.
Parameters
----------
app
App path.
Returns
-------
:class:`Div`
:class:`Div` class instance of the app layout.
"""
if app == app_1.APP_PATH:
return app_1.LAYOUT
elif app == app_2.APP_PATH:
return app_2.LAYOUT
else:
return Div(
[
P(
[
"Various colour science ",
A(
"Dash",
href="https://dash.plot.ly/",
target="_blank",
),
" apps built on top of \n",
A(
"Colour",
href="https://github.com/colour-science/colour",
target="_blank",
),
".",
]
),
H3(
[
Link(
app_1.APP_NAME,
href=app_1.APP_PATH,
className="app-link",
)
]
),
Markdown(app_1.APP_DESCRIPTION.replace("This app c", "C")),
H3(
[
Link(
app_2.APP_NAME,
href=app_2.APP_PATH,
className="app-link",
)
]
),
Markdown(app_2.APP_DESCRIPTION.replace("This app c", "C")),
]
)
if __name__ == "__main__":
APP.run_server(debug=True)