Download app.py from AneelSTR/PNT: direct link, hf CLI and curl.
- Browser
- Download file 2.75 kB
-
https://huggingface.co/spaces/AneelSTR/PNT/resolve/main/app.py
- Command line
-
hf download hf://spaces/AneelSTR/PNT/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AneelSTR/PNT/resolve/main/app.py
2.75 kB
| import streamlit as st | |
| import pandas as pd | |
| from pathlib import Path | |
| from PIL import Image | |
| import os | |
| # 1. Configuração da Página | |
| st.set_page_config(page_title="Portal PNT | ANEEL (beta)", layout="wide", page_icon="📊") | |
| # 2. CSS Global ANEEL | |
| st.markdown(""" | |
| <style> | |
| .stApp { background-color: #f4f7f9; } | |
| [data-testid="stSidebar"] { background-color: #002e52 !important; } | |
| .stSidebar [data-testid="stMarkdownContainer"] p { color: white !important; font-weight: bold; } | |
| .stSidebar .stRadio label { color: white !important; } | |
| .header-site { background-color: #004a80; padding: 20px; border-radius: 10px; color: white; margin-bottom: 20px; } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # 3. Carregamento de Dados Principal (Ajustado para base.csv) | |
| def load_data(): | |
| caminho_csv = "saida/base.csv" | |
| if os.path.exists(caminho_csv): | |
| df = pd.read_csv(caminho_csv, sep=';', decimal=',', encoding='utf-8-sig') | |
| else: | |
| df = pd.DataFrame(columns=['SigAgente', 'Ano', 'PNT']) | |
| return df | |
| df_raw = load_data() | |
| # 4. Barra Lateral - LOGO E NAVEGAÇÃO | |
| #caminho_logo = Path(r"E:\Aneel\Codigo_base_PNT_RI_Python_v2\paginas\imagens\logo_aneel_01.png") | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| caminho_logo = ROOT / "paginas" / "imagens" / "logo_aneel_01.png" | |
| with st.sidebar: | |
| st.markdown("<div style='margin-top: -50px;'></div>", unsafe_allow_html=True) | |
| if caminho_logo.exists(): | |
| logo_img = Image.open(caminho_logo) | |
| col_s1, col_s2, col_s3 = st.columns([1, 3, 1]) | |
| with col_s2: | |
| st.image(logo_img, width=130) | |
| st.markdown("<div style='margin-top: -20px;'></div>", unsafe_allow_html=True) | |
| menu = st.radio("NAVEGAÇÃO", [ | |
| "🏠 Início", | |
| "🔍 Ficha do Agente", | |
| "🗺️ Panorama Nacional", | |
| "⚖️ Benchmarking", | |
| #"🧠 Inteligência e Clusters", # Novo Botão | |
| #"⚙️ Área do Administrador" | |
| ], key="nav_main_2026") | |
| st.markdown("---") | |
| st.caption("ANEEL - v5.0") | |
| # 5. Roteamento | |
| if menu == "🏠 Início": | |
| from paginas.home import render_home | |
| render_home(df_raw) | |
| elif menu == "🔍 Ficha do Agente": | |
| from paginas.ficha import render_ficha | |
| render_ficha(df_raw, df_raw) | |
| elif menu == "🗺️ Panorama Nacional": | |
| from paginas.panorama import render_panorama | |
| render_panorama(df_raw) | |
| elif menu == "⚖️ Benchmarking": | |
| from paginas.comp import render_benchmarking | |
| render_benchmarking(df_raw) | |
| elif menu == "🧠 Inteligência e Clusters": | |
| from paginas.clusters import render_clusters | |
| render_clusters(df_raw) | |
| elif menu == "⚙️ Área do Administrador": | |
| from paginas.adm import render_adm | |
| render_adm() |