This is a simple, reproducible template for building internal tools using Streamlit and Railway. It's designed for researchers who want to quickly turn data scripts into interactive web applications and deploy them professionally.
Before the session starts, please ensure you have the following:
- GitHub Account
- Railway Account: Sign up here. You can log in with your GitHub account.
- Python Installed: Ensure you have Python 3.9+ on your local machine. I recommend
uvto manage your virtual environments and python packages.
# install uv using Homebrew
brew install uv
# shell autocomplete
# zsh
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc
# powershell
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Add-Content -Path $PROFILE -Value '(& uv generate-shell-completion powershell) | Out-String | Invoke-Expression'
Instead of cloning this template repo directly, use it to create your own copy on GitHub:
- Click the "Use this template" button at the top of this page.
- Select "Create a new repository".
- Choose your own profile as Owner.
- Choose a name (e.g.,
my-cool-app) and click "Create repository from template".
For more details, see the GitHub documentation on creating a repository from a template.
# 1. Clone YOUR new repository (replace 'your-username' and 'your-repo-name')
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
# 2. Install dependencies
# Using 'uv' (recommended):
uv pip install -r requirements.txt
# OR standard pip:
# pip install -r requirements.txt- Authentication:
- Rename
.streamlit/secrets.toml.exampleto.streamlit/secrets.toml. - Open the file and set your
password. - The app will now require this password to run locally.
- Rename
# Run the app
streamlit run app.pyWe use Railway because it provides a professional, "always-on" URL without the complexity of backend management.
- New Project: In Railway, click "New Project" -> "Deploy from GitHub repo".
- Select Repo: Choose the repository you just created from the template.
- Variables (The Important Part):
Railway needs to know two things to run your app professionally. Click on the app, go to the "Variables" tab and add:
PORT=8501password=your-chosen-password(This provides the secret to the cloud app without needing a secrets.toml file)
- Deploy Command: Click on the app, go to "Settings" tab. Under Deploy > Custom Start Command, paste the below:
streamlit run app.py --server.port $PORT --server.address 0.0.0.0 - Expose your App (Get the URL):
By default, Railway won't show your app to the public. To get a link:
- Click on the app
- Go to the "Settings" tab.
- Find the "Networking" section.
- Click "Generate Domain" (or add your own custom domain like
tools.yourlab.com). - Use port 8501 for listening, as that is what Streamlit listens on by default.
- Success! Click the new link to see your live, password-protected app.
The app.py file is pre-configured with:
- Professional Look: Hidden Streamlit branding for a "clean" feel.
- File Uploader: Drag and drop CSV/JSON files.
- Interactive Filters: Sliders and dropdowns that update charts in real-time.
- Security: A simple password gate for sharing with partners.
1. TabError: inconsistent use of tabs and spaces
- Problem: Python cannot mix Tabs and Spaces for indentation.
- The Fix:
- Open your editor (Cursor/VS Code).
- Press
Cmd + Shift + P(Mac) orCtrl + Shift + P(Windows). - Type "Convert Indentation to Spaces" and hit Enter.
- Save, commit, and push.
2. StreamlitSecretNotFoundError
- Problem: The app is looking for a password that hasn't been set.
- The Fix:
- Locally: Ensure
.streamlit/secrets.tomlexists. - Cloud: Ensure you have added the
passwordvariable in the Railway "Variables" tab.
- Locally: Ensure
st.write(): The "print" of Streamlit.st.dataframe(): Interactive tables.st.sidebar: Put controls on the left.st.columns(): Create side-by-side layouts.st.file_uploader(): Let users upload data.st.selectbox(): Dropdown menus.st.slider(): Numeric ranges.st.plotly_chart(): Interactive plots.st.map(): Geospatial visualizations.st.secrets: Securely handle passwords/API keys.
Built for the 1-Hour Researcher Workshop.