-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
81 lines (66 loc) · 2.07 KB
/
app.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
from dash import Dash, Input, Output, page_container
import plotly.io as pio
from components import Dashboard, Drawer, DrawerSingleItem, DrawerFooter, Navbar
# Instanciate Dash app
dash_app = Dash(
name=__name__,
title="Dados Abertos Brasil",
use_pages=True,
update_title="Buscando dados...",
)
# Create Drawer
nav_links = [
DrawerSingleItem(name="IBGE", icon="fa-solid:map-marker-alt", href="/ibge"),
DrawerSingleItem(name="IPEA", icon="icomoon-free:stats-bars", href="/ipea"),
DrawerSingleItem(name="Deputados", icon="map:political", href="/camara"),
DrawerSingleItem(
name="GitHub",
icon="akar-icons:github-fill",
href="https://github.com/GusFurtado/DadosAbertosBrasil",
),
DrawerFooter(
title="Gustavo Furtado",
subtitle="Cientista de Dados",
img_src="https://raw.githubusercontent.com/GusFurtado/MyWebsite/master/assets/profile_pic.JPG",
),
]
# Create Dashboard Layout
dash_app.layout = Dashboard(
children=page_container,
id="dashboard",
navbar=Navbar(title="Dados Abertos Brasil", id="dashboard-navbar"),
drawer=Drawer(
menu=nav_links,
logo_name="DAB",
logo_img="https://raw.githubusercontent.com/GusFurtado/dab_assets/main/images/favicon.ico",
),
)
@dash_app.callback(
Output("dashboard-navbar--title", "children"),
Input("dashboard--location", "pathname"),
)
def init_app(path):
"""Redirects to login page if user is not logged in.
Inputs
------
dashboard--location.pathname
Page the user is trying to access.
Outputs
-------
dashboard-navbar--title.children
Updated navbar title.
"""
try:
return {
"/ibge": "Indicadores Municipais",
"/ipea": "Séries Temporais",
"/camara": "Painel de Deputados",
}[path]
except KeyError:
return "Dados Abertos Brasil"
# Run app locally
app = dash_app.server
app.secret_key = "SECRET_KEY"
pio.templates.default = "plotly_white"
if __name__ == "__main__":
dash_app.run(host="0.0.0.0", port=1000)