Your first web app — in 10 lines
You are about to do something most people think requires months of web development: put a real, interactive web app on your screen. Ten lines of Python. No HTML, no CSS, no JavaScript.
Step 1: Install Streamlit
In your terminal (with your project's virtual environment active):
pip install streamlitStep 2: Create the app
Create a file called first_app.py:
import streamlit as st
st.title("🚀 My First App")
st.write("Hello! This is a real web app, built with Python.")
name = st.text_input("What is your name?")
if st.button("Greet me"):
st.success(f"Welcome, {name}! You are officially an app developer.")Step 3: Run it
streamlit run first_app.pyYour browser opens at localhost:8501 — type your name, press the button, and watch it respond. You just built a web app. Screenshot it. You'll want to remember this one.
How it actually works
The single most important idea in Streamlit — understand this and everything else becomes easy:
> Streamlit re-runs your entire script from top to bottom every time you interact with a widget.
Click the button? The script runs again, top to bottom. Type in the text box? Rerun. This is called the rerun model, and it's why Streamlit apps are just... Python scripts.
Walk through what happens on each rerun:
The script isn't "reacting to events" like JavaScript — it's simply re-executing and drawing a fresh page. That's the whole magic.
The vocabulary you now know
Common Errors & Fixes
--server.port 8502.What to try next
Before moving on, experiment: