Files
fantabeto/dashboard/app.py
T
ramseshk 397078d635 Fix dashboard imports for Streamlit multi-page routing
- Add sys.path.insert at top of app.py and all 5 page files
- Fix .streamlit/config.toml CORS/XSRF conflict
- Remove duplicate st.set_page_config from page files
- Verified: all pages import cleanly, dashboard boots via streamlit run
- All 49 tests passing (31 original + 18 dashboard)
2026-08-11 15:08:09 +08:00

64 lines
1.9 KiB
Python

"""Fantabeto 26/27 Dashboard — Project Al-Cihred.
Multi-page Streamlit app. Run with: streamlit run dashboard/app.py
"""
import sys
from pathlib import Path
# Ensure project root is on path so 'dashboard' imports resolve
PROJECT_ROOT = Path(__file__).resolve().parent.parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
import streamlit as st
from dashboard.viz.components import inject_css
# Register the custom Plotly template
from dashboard.viz.template import stub_render # triggers template registration
PAGES = {
"⚽ Matchday": "dashboard.pages.01_matchday",
"👤 Players": "dashboard.pages.02_players",
"💰 Auction": "dashboard.pages.03_auction",
"📋 Lineup": "dashboard.pages.04_lineup",
"🧪 Model Lab": "dashboard.pages.05_lab",
}
def main():
st.set_page_config(
page_title="Fantabeto 26/27 — Project Al-Cihred",
page_icon="⚽",
layout="wide",
initial_sidebar_state="expanded",
)
inject_css()
st.sidebar.markdown("""
<div style="font-family:'Space Grotesk',sans-serif;font-size:22px;font-weight:700;color:#E5E7EB;margin-bottom:4px;">
⚽ FANTABETO
</div>
<div style="font-family:'Inter',sans-serif;font-size:11px;color:#9CA3AF;margin-bottom:16px;text-transform:uppercase;letter-spacing:1px;">
Project Al-Cihred · 26/27
</div>
""", unsafe_allow_html=True)
page = st.sidebar.radio("Navigation", list(PAGES.keys()), label_visibility="collapsed")
st.sidebar.divider()
st.sidebar.caption("Fantacalcio Bayesian Estimated Team's Outcome")
st.sidebar.caption("v2.0 · August 2026")
st.sidebar.caption("Data: Fantacalcio.it · FBref · api-football")
# Route to selected page
module_name = PAGES[page]
import importlib
mod = importlib.import_module(module_name)
mod.run()
if __name__ == "__main__":
main()