How to host a Streamlit app online for free
Streamlit is the fastest way to turn a machine-learning model into a web app. Getting it online is where most students get stuck. Here's exactly how to do it, using a real house-price predictor as the example.
- Put
app.py,requirements.txtand your model or data files in the repo root. - Load files with paths relative to the script, and cache the model with
@st.cache_resource. - Push to GitHub and deploy on Shipzo. Streamlit's port and websockets are handled for you.
- Use the Standard plan for heavier libraries like scikit-learn or TensorFlow.
Live example: houseprice-predictor.shipzo.tech, a Streamlit + scikit-learn app deployed straight from GitHub with the steps below.
Step 1: Structure your repository
house-price-predictor/
├── app.py # your Streamlit app
├── model.pkl # trained model (or train it at start-up)
├── data.csv # any data files the app reads
├── requirements.txt
└── tests/
└── test_model.py # optional: runs before every deploy
Keep app.py in the root folder. If your app lives in a sub-folder, you can point the host to it later with a root directory setting.
Step 2: Pin your requirements
requirements.txt
streamlit>=1.39
pandas>=2.2
scikit-learn>=1.5
joblib>=1.4
Pin the scikit-learn version you trained with. A model pickled with one version can fail to load, or give different results, on another.
Step 3: Load files and models the right way
The most common Streamlit deploy error is FileNotFoundError. Paths that work on your laptop break on a server because the working directory is different. Build paths from the script's own location, and cache the model so it loads once instead of on every click:
app.py
from pathlib import Path
import joblib
import pandas as pd
import streamlit as st
BASE = Path(__file__).parent
@st.cache_resource
def load_model():
return joblib.load(BASE / "model.pkl")
@st.cache_data
def load_data():
return pd.read_csv(BASE / "data.csv")
st.title("🏠 House Price Predictor")
area = st.number_input("Area (sq ft)", 300, 10000, 1100, step=50)
bedrooms = st.slider("Bedrooms", 1, 6, 2)
if st.button("Predict"):
price = load_model().predict([[area, bedrooms]])[0]
st.metric("Estimated price", f"₹ {price:,.1f} lakh")
joblib.dump(model, "model.pkl", compress=3), or train it at start-up inside a cached function.Step 4: Push to GitHub
git init
git add .
git commit -m "Streamlit app"
git branch -M main
git remote add origin https://github.com/YOUR-USERNAME/house-price-predictor.git
git push -u origin main
Step 5: Deploy
- Sign up on Shipzo (free) and open New deployment.
- Paste the repo link.
- Choose Standard if you use scikit-learn, TensorFlow or PyTorch, or Starter for light apps. Then press Deploy.
Shipzo spots streamlit in your requirements and runs the equivalent of:
streamlit run app.py --server.port $PORT --server.address 0.0.0.0 --server.headless true
Streamlit talks to the browser over a websocket, which some proxies block (you'd see the app stuck on "Please wait…"). Shipzo passes websockets through, so this just works.
The first build of a data-science app takes 5–8 minutes because pandas and scikit-learn are large. Later deploys are faster.
Optional: test your model before every deploy
Add a quick pytest file and every push is checked before it goes live:
tests/test_model.py
from pathlib import Path
import joblib
MODEL = joblib.load(Path(__file__).parent.parent / "model.pkl")
def test_price_is_positive():
assert MODEL.predict([[1000, 2]])[0] > 0
def test_more_area_costs_more():
assert MODEL.predict([[2000, 2]])[0] > MODEL.predict([[1000, 2]])[0]
Common errors and fixes
| Problem | Fix |
|---|---|
FileNotFoundError for a CSV or model | Use Path(__file__).parent / "file", and make sure the file is committed (check .gitignore). |
| App stuck on "Please wait…" | Websockets are blocked by the host or a proxy. Shipzo supports them, so check your browser's network tab for errors. |
| Container restarts or is killed | Out of memory. Switch to the Standard or Pro plan, or load a lighter model. |
| Model gives errors after loading | The scikit-learn version differs from the one you trained with. Pin it in requirements.txt. |
| Every click is slow | Wrap model and data loading in @st.cache_resource / @st.cache_data. |
Deploy it in one click
Paste your GitHub repo into Shipzo. Tests, Docker build, HTTPS and monitoring are handled for you. Free during the beta, no card needed.
Create a free accountFrequently asked questions
Is Streamlit hosting free on Shipzo?
Yes, during the beta. Up to 3 projects per account, no card.
Can I deploy a Jupyter notebook?
Not directly. Move the code into app.py as a Streamlit app. That takes a few minutes and gives you a real interactive page.
Will my app sleep?
No. Apps keep running, so examiners and recruiters don't wait for a cold start.
Can I deploy Gradio or FastAPI instead?
FastAPI is detected automatically. For Gradio, set a custom start command in the project settings.