Update src/streamlit_app.py
Browse files- src/streamlit_app.py +14 -4
src/streamlit_app.py
CHANGED
|
@@ -32,10 +32,20 @@ st.markdown("""
|
|
| 32 |
""", unsafe_allow_html=True)
|
| 33 |
|
| 34 |
# ---------- Config & Secrets ----------
|
| 35 |
-
def get_apify_token()
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
APIFY_ACTOR_ID = "dSCLg0C3YEZ83HzYX" # your actor id
|
| 41 |
# If your actor expects a different input shape, adjust below.
|
|
|
|
| 32 |
""", unsafe_allow_html=True)
|
| 33 |
|
| 34 |
# ---------- Config & Secrets ----------
|
| 35 |
+
def get_apify_token():
|
| 36 |
+
import os, streamlit as st
|
| 37 |
+
# 1) try env var
|
| 38 |
+
env_token = os.getenv("APIFY_TOKEN")
|
| 39 |
+
# 2) try secrets.toml, but don't crash if it's missing
|
| 40 |
+
secret_token = None
|
| 41 |
+
try:
|
| 42 |
+
# access st.secrets inside try/except because it raises if file is missing
|
| 43 |
+
secret_token = st.secrets.get("APIFY_TOKEN", None) # type: ignore
|
| 44 |
+
except FileNotFoundError:
|
| 45 |
+
secret_token = None
|
| 46 |
+
except Exception:
|
| 47 |
+
secret_token = None
|
| 48 |
+
return secret_token or env_token
|
| 49 |
|
| 50 |
APIFY_ACTOR_ID = "dSCLg0C3YEZ83HzYX" # your actor id
|
| 51 |
# If your actor expects a different input shape, adjust below.
|