-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.py
48 lines (36 loc) · 1.2 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
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import pandas as pd
from app import app, server
from apps import dashboard, dashboard2
csv = "mydatastore.csv"
# Add global app methods here
def get_database():
db = pd.read_csv(csv)
return db
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(children=[
html.H1(children='Plotly Dash Multipage Template App'),
html.Div(children=[
html.A(html.Button('Dashboard', className='tab-button'),
href='/'),
html.A(html.Button('Dashboard2', className='tab-button'),
href='/'),
], className='tabs'),
], className='nav'),
html.Div(id='page-content'),
])
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
df = get_database()
if pathname == '/':
return dashboard.get_dashboard_layout(df)
elif pathname == '/dashboard2':
return dashboard2.get_dashboard2_layout(df)
else:
return dashboard.get_dashboard_layout(df)
if __name__ == '__main__':
app.run_server(debug=True)