-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
83 lines (69 loc) · 2.44 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
##################MULTI PAGE APP DASH ################
# Prueba de una aplicacion con diferentes paginas - implementando un menu
# Manage the different apps on different urls with the callbacks
# Entry point for running the app
# This file links up all the individual pages (it is possible to add a navigation bar that is common to the rest of files)
# Tb se puede modificar el index_string de la App que permite fijar un menu, footer, etc
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output
from app import app
from apps import app1, app2
app.layout = html.Div([
html.Div([
dbc.Navbar(
dbc.Container([
html.A(
dbc.Row(
[
dbc.Col(dbc.NavbarBrand("Madrid City Observatory", className="ml-2")),
],
align="center",
no_gutters=True,
),
href="/home",
),
# Genera el menu con el componente de bootstrap
dbc.Nav(
[
dbc.NavLink("City Observatory", active=True, href="/home", style={'color': 'grey'}),
dbc.NavLink("About", href="#", style={'color': 'grey'}),
dbc.NavLink(
html.A('Contact', href='mailto:[email protected]'
, style={'color': 'grey'}),
),
]
)
],
className='floating menu row', style={'max-width': '2000px'}
),
color="dark",
dark=True,
className="mb-4",
),
], style={'padding-right': '-15px', 'padding-left': '-15px'}
),
html.Hr(),
html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content'),
], className='container-fluid'
)
]
)
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/':
return app1.layout
if pathname == '/home':
return app1.layout
elif pathname == '/apps/app2':
return app2.layout
else:
return '404'
#START THE SERVER
#server = app.server
#if __name__ == '__main__':
# app.run_server(debug=True)