Introduction
Streamlit Colab is a command-line tool that allows you to run Streamlit applications with ngrok tunneling. This makes your local Streamlit app accessible via a public URL, which is especially useful for sharing your app with others or for testing purposes.
Installation
To install Streamlit Colab, follow these steps:
pip install streamlit-colab
Usage
Run your Streamlit app with ngrok tunneling using the following command:
stc <app.py> <ngrok_token> [port]
Parameters:
<app.py>: Path to your Streamlit application file.<ngrok_token>: Your ngrok authentication token.[port]: (Optional) Custom port to run the Streamlit app on. Defaults to8501if not specified.
Examples
1. Running with Default Port (8501)
To run your Streamlit app on the default port 8501:
stc /path/to/your/app.py <your_ngrok_token>
2. Running with a Custom Port (e.g., 5005)
To run your Streamlit app on a custom port, such as 5005:
stc /path/to/your/app.py <your_ngrok_token> 5005
3. Using an Environment Variable for ngrok Token
You can set the ngrok token as an environment variable and omit it from the command:
export NGROK_TOKEN=<your_ngrok_token>
stc /path/to/your/app.py
Note: This will default to port 8501.
To override the port:
stc /path/to/your/app.py 5005