generated from rrherr/dash-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
82 lines (72 loc) · 3.53 KB
/
run.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
# Imports from 3rd party libraries
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Imports from this application
from app import app, server
from pages import index, process
"""
https://dash-bootstrap-components.opensource.faculty.ai/l/components/navbar
NavbarSimple consists of a 'brand' on the left, to which you can attach a link
with brand_href, and a number nav items as its children. NavbarSimple will
collapse on smaller screens, and add a toggle for revealing navigation items.
brand (string, optional): Brand text, to go top left of the navbar.
brand_href (string, optional): Link to attach to brand.
children (a list of or a singular dash component, string or number, optional): The children of this component
color (string, optional): Sets the color of the NavbarSimple. Main options are primary, light and dark, default light. You can also choose one of the other contextual classes provided by Bootstrap (secondary, success, warning, danger, info, white) or any valid CSS color of your choice (e.g. a hex code, a decimal code or a CSS color name)
dark (boolean, optional): Applies the `navbar-dark` class to the NavbarSimple, causing text in the children of the Navbar to use light colors for contrast / visibility.
light (boolean, optional): Applies the `navbar-light` class to the NavbarSimple, causing text in the children of the Navbar to use dark colors for contrast / visibility.
sticky (string, optional): Stick the navbar to the top or the bottom of the viewport, options: top, bottom. With `sticky`, the navbar remains in the viewport when you scroll. By contrast, with `fixed`, the navbar will remain at the top or bottom of the page.
"""
navbar = dbc.NavbarSimple(
brand='Coral Death',
brand_href='/',
children=[
dbc.NavItem(dcc.Link('Process', href='/process', className='nav-link')),
],
color=None,
light=True, #This is for the text
dark=False
)
footer = dbc.Container(
dbc.Row(
dbc.Col(
html.P(
[
html.Span('Jason Nova', className='mr-4 name'),
html.A(html.I(className='fas fa-paw mr-3'), href='https://www.worldwildlife.org/initiatives/oceans'),
html.A(html.I(className='fas fa-envelope-square mr-3'), href='mailto:jasonnova@protonmail.com'),
html.A(html.I(className='fab fa-github-square mr-3'), href='https://github.com/jeibloo/coral-death'),
html.A(html.I(className='fab fa-linkedin mr-3'), href='https://www.linkedin.com/in/jason-nova/'),
html.A(html.I(className='fab fa-twitter-square mr-3'), href='https://twitter.com/jsn404'),
html.Img(className='logo',src=app.get_asset_url('logoT.png')),
],
className='lead',
)
),
align='end'
),
className='footer'
)
# For more explanation, see:
# Plotly Dash User Guide, URL Routing and Multiple Apps
# https://dash.plot.ly/urls
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
navbar,
dbc.Container(id='page-content', className='mt-6'),
footer
])
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/':
return index.layout
elif pathname == '/process':
return process.layout
else:
return dcc.Markdown('## Page not found')
if __name__ == '__main__':
app.run_server(debug=True)