-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
44 lines (33 loc) · 1.06 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
# Import necessary libraries
from dash import html, dcc
from dash.dependencies import Input, Output
# Connect to main app.py file
from application import app, server
# Connect to your app pages
from pages import page1, page2
# Connect the navbar to the index
from components import navbar, pagprincipal
# Define the navbar
nav = navbar.Navbar()
# Define the pagina principal
pag = pagprincipal.pagprin()
# Define the index page layout
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
nav,
pag,
html.Div(id='page-content', children=[]),
])
# Create the callback to handle mutlipage inputs
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/page1':
return page1.layout
if pathname == '/page2':
return page2.layout
else: # if redirected to unknown link
return "404 Page Error! Please choose a link"
# Run the app on localhost:8050
if __name__ == '__main__':
app.run_server(debug = False, port=8000, host='0.0.0.0')