Fix Streamlit server deployment: headless mode, default 7-day range, error handling
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9d007563ca
commit
35d5bec8cc
@ -1,2 +1,5 @@
|
||||
[server]
|
||||
port = 15001
|
||||
headless = true
|
||||
enableCORS = false
|
||||
enableXsrfProtection = false
|
||||
|
||||
@ -87,10 +87,11 @@ def _load_detail(campaign_id: str, date_from: str, date_to: str):
|
||||
st.sidebar.title("Filtros")
|
||||
today = date.today()
|
||||
yesterday = today - timedelta(days=1)
|
||||
default_from = yesterday - timedelta(days=6) # últimos 7 días por defecto
|
||||
first_of_month = today.replace(day=1)
|
||||
|
||||
c1, c2 = st.sidebar.columns(2)
|
||||
date_from = c1.date_input("Desde", value=first_of_month, max_value=yesterday)
|
||||
date_from = c1.date_input("Desde", value=default_from, max_value=yesterday)
|
||||
date_to = c2.date_input("Hasta", value=yesterday, min_value=date_from, max_value=yesterday)
|
||||
|
||||
if st.sidebar.button("🔄 Actualizar", use_container_width=True):
|
||||
@ -105,7 +106,11 @@ if date_from > date_to:
|
||||
|
||||
# ── Data ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
daily_rows, campaign_metrics, vertical_cpls = _load_data(date_from_str, date_to_str)
|
||||
try:
|
||||
daily_rows, campaign_metrics, vertical_cpls = _load_data(date_from_str, date_to_str)
|
||||
except Exception as _e:
|
||||
st.error(f"Error cargando datos de Meta API: {_e}")
|
||||
st.stop()
|
||||
|
||||
# Aggregate daily totals with per-vertical margins
|
||||
_daily: dict = {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user