A working data dashboard with filters, charts, and a KPI summary panel — deployed locally and ready to share via a public URL.
Streamlit: Dashboard in 30 Lines
$ pip install streamlit plotly pandasimport streamlit as st
import plotly.express as px
import pandas as pd
st.title("Sales Dashboard")
# KPI metrics in columns
col1, col2, col3 = st.columns(3)
col1.metric("Total Revenue", "$342,000", "+12%")
col2.metric("New Customers", "148", "+8")
col3.metric("Avg Deal Size", "$2,310", "-3%")
# Filter
df = px.data.gapminder()
continent = st.selectbox("Continent", df["continent"].unique())
filtered = df[df["continent"] == continent]
# Chart updates automatically when filter changes
fig = px.line(filtered, x="year", y="lifeExp",
color="country", title=f"{continent}: Life Expectancy")
st.plotly_chart(fig, use_container_width=True)Run with: streamlit run dashboard.py. Opens in your browser instantly. The selectbox automatically reruns the whole script when you change the value — that's Streamlit's magic.
Adding More Streamlit Components
Streamlit has a rich component library for interactive dashboards:
import streamlit as st
import pandas as pd
# Sidebar filters
with st.sidebar:
st.header("Filters")
year_range = st.slider("Year Range", 2020, 2025, (2022, 2025))
show_table = st.checkbox("Show raw data")
# File upload
uploaded = st.file_uploader("Upload CSV", type=["csv"])
if uploaded:
df = pd.read_csv(uploaded)
st.success(ff"Loaded {len(df)} rows")
if show_table:
st.dataframe(df)Deploy Your Dashboard
Streamlit has free hosting at streamlit.io/cloud. Push your app to GitHub, connect the repo, done.
Push your dashboard.py and requirements.txt to a GitHub repo.
Go to share.streamlit.io → "Deploy an app" → connect your GitHub repo.
Select your main file (dashboard.py), click Deploy. Your app gets a public URL in about 2 minutes.
Free tier limits: Streamlit Cloud's free tier is generous — 1 app per account with no usage limits for public apps. For multiple apps or private apps, upgrade. For serious production use, deploy to Railway or similar.
What You Learned Today
- How Streamlit's reactive execution model works: every user interaction reruns the script
- st.metric for KPIs, st.selectbox/slider/checkbox for filters, st.sidebar for layout
- How to handle file uploads and dynamically generated charts
- The one-click deployment process with Streamlit Cloud
Go Further on Your Own
- Build a dashboard for a real dataset you use at work. Add at least 2 filters and 3 charts.
- Add a 'Download as CSV' button to your dashboard using st.download_button()
- Build a comparison view: show the same metric for two time periods side by side using st.columns()
Nice work. Keep going.
Day 5 is ready when you are.
Continue to Day 5Want live instruction and hands-on projects? Join the AI bootcamp — 3 days, 5 cities.