Starberry15 commited on
Commit
026497d
·
verified ·
1 Parent(s): 5e0cf9a

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -3
src/streamlit_app.py CHANGED
@@ -26,8 +26,12 @@ from huggingface_hub import InferenceClient
26
  # ---------- CONFIGURATION ----------
27
  st.set_page_config(page_title="Data Analysis App", layout="wide")
28
 
29
- # Load HF token
30
- HF_TOKEN = st.secrets.get("HF_TOKEN", os.getenv("HF_TOKEN"))
 
 
 
 
31
  if not HF_TOKEN:
32
  st.warning("⚠️ HF_TOKEN not found. Please add it to your Hugging Face Space secrets or environment.")
33
  else:
@@ -229,7 +233,7 @@ if uploaded_file:
229
  second_col = st.selectbox("Second column", options=[c for c in cleaned_df.columns if c != viz_col])
230
 
231
  if st.button("Show Visualization"):
232
- fig, ax = plt.subplots(figsize=(8,5))
233
  try:
234
  if viz_type == 'Histogram':
235
  sns.histplot(cleaned_df[viz_col], kde=True, ax=ax)
 
26
  # ---------- CONFIGURATION ----------
27
  st.set_page_config(page_title="Data Analysis App", layout="wide")
28
 
29
+ # Safe HF_TOKEN loader (works locally + on Spaces)
30
+ try:
31
+ HF_TOKEN = st.secrets["HF_TOKEN"]
32
+ except Exception:
33
+ HF_TOKEN = os.getenv("HF_TOKEN")
34
+
35
  if not HF_TOKEN:
36
  st.warning("⚠️ HF_TOKEN not found. Please add it to your Hugging Face Space secrets or environment.")
37
  else:
 
233
  second_col = st.selectbox("Second column", options=[c for c in cleaned_df.columns if c != viz_col])
234
 
235
  if st.button("Show Visualization"):
236
+ fig, ax = plt.subplots(figsize=(8, 5))
237
  try:
238
  if viz_type == 'Histogram':
239
  sns.histplot(cleaned_df[viz_col], kde=True, ax=ax)