๐Ÿ› Fix: Space crashes on startup - Password authentication & deprecated package

#2
by akseljoonas - opened

Problem

The space crashes on startup due to two issues:

1. Missing secrets.toml file

The app tries to access st.secrets["app_password"] but the .streamlit/secrets.toml file isn't available in the repository, causing a KeyError that crashes the app.

2. Deprecated package in requirements.txt

The package extra-streamlit-components is deprecated and causes build warnings/errors.

Solution

I've created a fixed version of the space at: https://huggingface.co/spaces/akseljoonas/EXVAL-fixed

Changes Made:

1. app.py - Line ~27

Before:

if st.session_state["password"] == st.secrets["app_password"]:

After:

if st.session_state["password"] == st.secrets.get("app_password", os.environ.get("APP_PASSWORD", "demo123")):

Also added import os at the top of the file.

This change allows the password to be:

  • Set via .streamlit/secrets.toml (existing method)
  • Set via APP_PASSWORD environment variable in Space Settings
  • Default to "demo123" for demo/testing purposes

2. requirements.txt

Before:

streamlit
pandas
matplotlib
extra-streamlit-components  # โ† REMOVE THIS LINE
streamlit-toggle
streamlit-tags
streamlit-vertical-slider
reportlab

After:

streamlit
pandas
matplotlib
streamlit-toggle
streamlit-tags
streamlit-vertical-slider
reportlab

How to Apply the Fix

Option 1: Clone the fixed space

You can duplicate/fork https://huggingface.co/spaces/akseljoonas/EXVAL-fixed which already has these fixes applied.

Option 2: Manual fix

  1. Edit app.py and change line 27 as shown above (add import os at top)
  2. Edit requirements.txt and remove the extra-streamlit-components line
  3. Add APP_PASSWORD to Space Settings > Variables and secrets

Testing

The fixed space is live and working at https://huggingface.co/spaces/akseljoonas/EXVAL-fixed

Test password: demo123 (or set your own via APP_PASSWORD env var)

Let me know if you'd like me to submit these changes as a pull request!

Sign up or log in to comment