What Is Streamlit? Build Data Apps in Pure Python
Streamlit turns a Python script into an interactive web app — charts, tables, inputs and chat interfaces — without writing HTML or JavaScript. How it works, a minimal example, what it's great for (dashboards, AI demos, internal tools), its limits, and how to deploy it.
Streamlit is an open-source Python library that turns a script into a web app. You write Python; Streamlit draws the interface — sliders, buttons, tables, charts, file uploads, chat boxes — in the browser. No HTML, CSS or JavaScript.
It's hugely popular with data scientists, analysts and anyone building AI demos.
A minimal example
# app.py
import streamlit as st
import pandas as pd
st.title("Sales explorer")
uploaded = st.file_uploader("Upload a CSV", type="csv")
if uploaded:
df = pd.read_csv(uploaded)
region = st.selectbox("Region", sorted(df["region"].unique()))
filtered = df[df["region"] == region]
st.metric("Total sales", f"{filtered['amount'].sum():,.0f}")
st.bar_chart(filtered, x="month", y="amount")
st.dataframe(filtered)
pip install streamlit pandas
streamlit run app.py
A browser opens with a working app.
How it works (and why it feels different)
Streamlit reruns your whole script from top to bottom every time someone interacts — moves a slider, clicks a button. Each st. call draws part of the page.
That makes it very simple to reason about, with two consequences:
Expensive work must be cached, or it reruns on every click:
@st.cache_data def load_data(): return pd.read_csv("big.csv")Values you want to keep between reruns go in
st.session_state.
What it's great for
- Dashboards over data or a database
- AI demos and chat interfaces —
st.chat_inputandst.chat_messagemake a chatbot UI in a few lines (How to add an AI chatbot) - Internal tools — admin views, data cleaning, reports for a team
- Prototypes to show stakeholders quickly
- Machine-learning model front-ends
Its limits
- Customising the look beyond its components is limited; it always looks like a Streamlit app.
- Complex, multi-page products with intricate state get awkward.
- Each user session holds a connection and memory on the server, so very high traffic needs more resources than a typical web app.
- Authentication is basic; for anything sensitive you'll add proper login. (Add login to an AI-built app)
When an internal tool becomes a customer-facing product, teams often move the front-end to React and keep Python as an API. (What is FastAPI?)
Alternatives
- Gradio — similar, focused on ML model demos.
- Dash (Plotly) — more control, more code.
- NiceGUI, Reflex, Panel — other Python-first UI frameworks.
Deploying it
- Streamlit Community Cloud — free hosting for public apps from a GitHub repo; apps sleep when unused.
- Your own server — run
streamlit run app.py --server.port 8501 --server.address 127.0.0.1as a service, behind a reverse proxy with HTTPS. Streamlit uses WebSockets, so the proxy must allow them. (WebSockets explained, Reverse proxies) - Docker — common for company deployments.
Keep secrets (database passwords, API keys) in environment variables or Streamlit's secrets.toml — never in the code you push. (Environment variables)
EasySpawn runs your Streamlit app on an always-on server — no sleeping — behind HTTPS with WebSockets working, next to the database it reads from. See how it works or join the waitlist.
Related: What Is Python? · What Is FastAPI? · How to Run a Python Script 24/7 · Python Virtual Environments
Keep reading
What Is llms.txt? A Guide for AI-Readable Websites
llms.txt is a proposed Markdown file at your site's root that gives AI tools a concise, curated map of your content. What goes in it, the format, llms-full.txt, how it differs from robots.txt and sitemap.xml, who actually reads it today, and how to add one in Next.js.
"ReferenceError: window is not defined" in Next.js: How to Fix It
window, document and localStorage only exist in the browser. Next.js renders components on the server first, where they don't exist. Why it happens, and the fixes: useEffect, 'use client', typeof checks, dynamic imports with ssr: false, and libraries that touch window on import.