st-codespaces
st-codespaces copied to clipboard
Template to run Streamlit apps on GitHub Codespaces
Run Streamlit on Codespaces
Fork this repo, add your Streamlit app to it, and run it on GitHub Codespaces. :balloon:
How it works
-
.devcontainer/devcontainer.jsoncreates a container with Python 3.10, installs your app dependencies fromrequirements.txt, and launchesstreamlit hello.- Edit the
postAttachCommandto launch your app instead of Streamlit Hello. E.g. if your script isapp.py:"postAttachCommand": "streamlit run app.py",
- Edit the
-
It uses
forwardPortsto make port8501inside the container available locally. -
Additionally, it sets the following configuration options in
.streamlit/config.tomlso that the app can be run on Codespaces without the addition of command line arguments:[server] enableCORS = false enableXsrfProtection = false
Example usage
Fork this repo, open it on GitHub Codespaces, wait for the container to load, and click the "Open in browser" button in the bottom right corner when it appears to open the Hello app:
If it weren't for the .streamlit/config.toml file, you would have had to run the following command:
streamlit hello --server.enableCORS false --server.enableXsrfProtection false