forked from mithi/hexapod-robot-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
60 lines (51 loc) · 1.18 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
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from app import app
from pages import page_inverse, page_kinematics, page_test
# --------------
# Navigation bar partial
# --------------
div_nav = html.Div([
dcc.Link('Kinematics', href='/kinematics'),
html.Br(),
dcc.Link('Inverse Kinematics', href='/inverse-kinematics'),
html.Br(),
dcc.Link('Test: basic changes', href='/test'),
html.Br(),
dcc.Link('Root', href='/'),
html.Br(),
])
# --------------
# Layout
# --------------
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content'),
div_nav,
])
# --------------
# URL redirection
# --------------
PAGES = {
'/inverse-kinematics': page_inverse.layout,
'/kinematics': page_kinematics.layout,
'/test': page_test.layout
}
# --------------
# Display page given URL
# --------------
@app.callback(
Output('page-content', 'children'),
[Input('url', 'pathname')]
)
def display_page(pathname):
try:
return PAGES[pathname]
except KeyError:
return 'Hello world!'
# --------------
# Run server
# --------------
if __name__ == '__main__':
app.run_server(debug=True)