-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
45 lines (38 loc) · 1.24 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
import os
from dash import dcc, html
from dash.dependencies import Input, Output
from app1.pages.sidebar import app1_sidebar
from app1.routes import app1_urlpatterns
from dash_app.app import app
from dash_app.base.urls import display_page
from dash_app.base.utils import setup_logging
from dash_app.config import BASE_PATH
LOGGING_CONFIG_PATH = os.path.join(BASE_PATH, 'dash_app/logging.yaml')
"""
main app layout, which has a component to track the url, and rest are
div to store sidebar, and content
"""
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='sidebar'),
html.Div(id='page-content',
style={
"margin-left": "18rem",
"margin-right": "2rem",
"padding": "2rem 1rem",
})
])
@app.callback(Output('page-content', 'children'),
Output('sidebar', 'children'), Input('url', 'pathname'))
def display_app(pathname):
"""
callback function to update the correct app related
routes to the main app
"""
if pathname.split('/')[1] == 'app':
return display_page(pathname, app1_urlpatterns), app1_sidebar
else:
return '404'
if __name__ == "__main__":
setup_logging()
app.run_server(debug=True)