forked from agahkarakuzu/rrsg2020-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
42 lines (36 loc) · 1.13 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
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
import uuid
from app import app
from apps import home, phantom, brain, stats
#app.layout = html.Div([
# dcc.Location(id='url', refresh=False),
# html.Div(id='page-content'),
# dcc.Link('CHANGE URL', href='/apps/home'),
# html.Div(session_id, id='session-id', style={'display': 'none'})
#])
server = app.server
def serve_layout():
session_id = str(uuid.uuid4())
return html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content'),
html.Div(session_id, id='session-id', style={'display': 'none'})
])
app.layout = serve_layout
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/':
return home.layout
elif pathname == '/apps/phantom':
return phantom.layout
elif pathname == '/apps/brain':
return brain.layout
elif pathname == '/apps/stats':
return stats.layout
else:
return '404'
if __name__ == '__main__':
app.run_server(debug=True)