-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.py
More file actions
42 lines (32 loc) · 1.11 KB
/
dashboard.py
File metadata and controls
42 lines (32 loc) · 1.11 KB
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
# dashboard.py
import dash
import dash_bootstrap_components as dbc
from dash import dcc, html
from dash.dependencies import Input, Output
import requests
from layout import create_layout
# Inicialize o Dash app
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
# Definir o layout do Dash app
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])
# Função para obter o conteúdo da página do Flask
def fetch_flask_page(url):
response = requests.get(url)
return response.content.decode('utf-8')
# Callback para atualizar o conteúdo da página
@app.callback(
Output('page-content', 'children'),
[Input('url', 'pathname')]
)
def display_page(pathname):
if pathname == '/graficos/':
return create_layout()
elif pathname == '/matriz-curricular':
return html.Div(fetch_flask_page('http://localhost:5000/matriz-curricular'))
else:
return '404 - Página não encontrada'
if __name__ == '__main__':
app.run_server(debug=True, port=8050) # Executar o Dash na porta 8050