Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +23 -1
src/streamlit_app.py
CHANGED
|
@@ -104,10 +104,32 @@ def apply_vortex_style():
|
|
| 104 |
# ==============================================================================
|
| 105 |
@st.cache_resource
|
| 106 |
def get_gspread_client():
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
if not raw_json:
|
| 109 |
st.error("🛑 Secret 'GSHEETS_JSON' manquant.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
return None
|
|
|
|
| 111 |
try:
|
| 112 |
creds_dict = json.loads(raw_json)
|
| 113 |
credentials = Credentials.from_service_account_info(
|
|
|
|
| 104 |
# ==============================================================================
|
| 105 |
@st.cache_resource
|
| 106 |
def get_gspread_client():
|
| 107 |
+
# Essayer d'abord les variables d'environnement
|
| 108 |
+
raw_json = os.environ.get("GSHEETS_JSON")
|
| 109 |
+
|
| 110 |
+
# Si pas trouvé, essayer secrets.toml
|
| 111 |
+
if not raw_json:
|
| 112 |
+
try:
|
| 113 |
+
raw_json = st.secrets.get("GSHEETS_JSON")
|
| 114 |
+
except:
|
| 115 |
+
raw_json = None
|
| 116 |
+
|
| 117 |
if not raw_json:
|
| 118 |
st.error("🛑 Secret 'GSHEETS_JSON' manquant.")
|
| 119 |
+
st.info("""
|
| 120 |
+
**Deux options pour configurer :**
|
| 121 |
+
|
| 122 |
+
**Option 1 - Variable d'environnement :**
|
| 123 |
+
```bash
|
| 124 |
+
export GSHEETS_JSON='{"type": "service_account", ...}'
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
**Option 2 - Fichier secrets.toml :**
|
| 128 |
+
1. Créez `.streamlit/secrets.toml`
|
| 129 |
+
2. Ajoutez votre JSON Google Sheets
|
| 130 |
+
""")
|
| 131 |
return None
|
| 132 |
+
|
| 133 |
try:
|
| 134 |
creds_dict = json.loads(raw_json)
|
| 135 |
credentials = Credentials.from_service_account_info(
|