diff --git a/domo91.py b/domo91.py index 26f5fe7..4473fe9 100644 --- a/domo91.py +++ b/domo91.py @@ -18,7 +18,6 @@ db_config = { "password": "#SO2&1nf%mZ@jfh", "database": "Sondes" } - # --- Fonction de génération PDF --- def generer_pdf(site, date_str): st.info(f"Génération du rapport PDF pour {site} à la date {date_str}") @@ -81,7 +80,10 @@ def generer_pdf(site, date_str): pdf.alertes_section(alertes) file_name = f"rapport_{site}_{date_str}.pdf" - output_path = os.path.join("PDF", file_name) + output_dir = "PDF" + os.makedirs(output_dir, exist_ok=True) # 🔧 Crée le dossier si absent + output_path = os.path.join(output_dir, file_name) + pdf.output(output_path) with open(output_path, "rb") as f: @@ -94,7 +96,6 @@ def generer_pdf(site, date_str): except Exception as e: st.error(f"Erreur lors de la génération du PDF : {e}") - # --- Initialisation session --- if "authenticated" not in st.session_state: st.session_state["authenticated"] = False @@ -199,3 +200,4 @@ if st.session_state["authenticated"]: except Exception as e: st.error(f"Erreur MySQL : {e}") +