Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snehankekre/st-codespaces
Template to run Streamlit apps on GitHub Codespaces
https://github.com/snehankekre/st-codespaces
codespaces streamlit
Last synced: 3 months ago
JSON representation
Template to run Streamlit apps on GitHub Codespaces
- Host: GitHub
- URL: https://github.com/snehankekre/st-codespaces
- Owner: snehankekre
- Created: 2022-06-15T05:04:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T04:58:58.000Z (over 1 year ago)
- Last Synced: 2024-10-30T01:31:00.238Z (3 months ago)
- Topics: codespaces, streamlit
- Homepage:
- Size: 8.79 KB
- Stars: 28
- Watchers: 4
- Forks: 63
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Run Streamlit on Codespaces
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/snehankekre/st-codespaces?quickstart=1)
Fork this repo, add your Streamlit app to it, and run it on GitHub Codespaces. :balloon:
## How it works
- `.devcontainer/devcontainer.json` creates a container with Python 3.10, installs your app dependencies from `requirements.txt`, and launches `streamlit hello`.
- Edit the `postAttachCommand` to launch your app instead of Streamlit Hello. E.g. if your script is `app.py`:
```json
"postAttachCommand": "streamlit run app.py",
```
- It uses `forwardPorts` to make port `8501` inside the container available locally.
- Additionally, it sets the following configuration options in `.streamlit/config.toml` so that the app can be run on Codespaces without the addition of command line arguments:```toml
[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:
![st-codespaces](https://github.com/snehankekre/st-codespaces/assets/20672874/9e31e47f-1fce-4213-a973-e7ed1259a480)
If it weren't for the `.streamlit/config.toml` file, you would have had to run the following command:
```bash
streamlit hello --server.enableCORS false --server.enableXsrfProtection false
```