klydekushy commited on
Commit
6ea973b
·
verified ·
1 Parent(s): dee9717

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +19 -3
src/streamlit_app.py CHANGED
@@ -2,10 +2,14 @@ import streamlit as st
2
  from streamlit_gsheets import GSheetsConnection
3
  import pandas as pd
4
 
 
 
 
 
5
  # 1. CONFIGURATION DE LA PAGE
6
  st.set_page_config(
7
  page_title="Vortex-Flux | Ontology",
8
- page_icon="🌀",
9
  layout="wide",
10
  initial_sidebar_state="expanded"
11
  )
@@ -57,8 +61,20 @@ st.markdown("""
57
  """, unsafe_allow_html=True)
58
 
59
  # 3. CONNEXION À L'ONTOLOGIE (GOOGLE SHEETS)
60
- # Remplacer l'ancienne ligne de connexion par celle-ci
61
- conn = st.connection("gsheets", type=GSheetsConnection, credentials=st.secrets["GSHEETS_CREDENTIALS"])
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  # 4. FONCTION GÉNÉRATRICE D'ID UNIQUE (ONTOLOGIE)
64
  def generate_ontology_id(prefix, sheet_name):
 
2
  from streamlit_gsheets import GSheetsConnection
3
  import pandas as pd
4
 
5
+ import os
6
+ import json
7
+ import toml
8
+
9
  # 1. CONFIGURATION DE LA PAGE
10
  st.set_page_config(
11
  page_title="Vortex-Flux | Ontology",
12
+ page_icon="🔺🔻",
13
  layout="wide",
14
  initial_sidebar_state="expanded"
15
  )
 
61
  """, unsafe_allow_html=True)
62
 
63
  # 3. CONNEXION À L'ONTOLOGIE (GOOGLE SHEETS)
64
+
65
+ # Tentative de récupération des credentials
66
+ creds = None
67
+ if "GSHEETS_CREDENTIALS" in st.secrets:
68
+ creds = st.secrets["GSHEETS_CREDENTIALS"]
69
+ elif "GSHEETS_CREDENTIALS" in os.environ:
70
+ # Si c'est stocké comme une chaîne de caractères dans l'OS
71
+ creds = toml.loads(os.environ["GSHEETS_CREDENTIALS"])
72
+
73
+ if creds:
74
+ conn = st.connection("gsheets", type=GSheetsConnection, credentials=creds)
75
+ else:
76
+ st.error("ERREUR CRITIQUE : Identifiants GSHEETS_CREDENTIALS introuvables.")
77
+ st.stop()
78
 
79
  # 4. FONCTION GÉNÉRATRICE D'ID UNIQUE (ONTOLOGIE)
80
  def generate_ontology_id(prefix, sheet_name):