Stario Deep Dive: Building Real-time Python Apps

Опубликовано: 25 Август 2026
на канале: Adam Bobowski
336
14

A complete walkthrough of Stario, a Python web framework for real-time applications. We build a multiplayer tile game and explain every concept along the way.

This is a deep dive into how Stario thinks about web development: explicit configuration, handler signatures, streaming responses, and Datastar integration.

---

⏱️ Timestamps

0:00 Introduction & Demo
2:00 Project Structure
4:00 Tracers (RichTracer vs JsonTracer)
8:30 The Stario Application
10:00 Static Assets & Fingerprinting
12:30 Route Registration
14:00 Handler Signature (Context, Writer)
16:30 Context Object Deep Dive
23:00 Writer Object Deep Dive
31:30 The w.alive Pattern
43:00 The Click Handler & Background Tasks
50:00 HTML Generation
58:00 Datastar Integration (data.* and at.*)
1:05:00 Summary & Wrap Up

---

🔑 Key Concepts

*Handler Signature*
Every handler: async def handler(c: Context, w: Writer) - None
Context: request data, signals, tracing, state
Writer: send responses, stream updates, manage connection

*Three Handler Patterns*
1. Quick response: w.html() - send and done
2. Streaming: w.alive() loop with w.patch()
3. Background: w.empty() then continue processing

*Writer Methods*
w.html(element) - full HTML response
w.patch(element) - SSE DOM update
w.empty(204) - close connection, continue handler
w.alive(iterator) - loop until disconnect

*Datastar Integration*
data.signals() - reactive state
data.on() - event handlers
data.init() - on load actions
at.get(), at.post() - server actions

---

🔗 Links

Stario: https://github.com/starfederation/stario
Docs: https://stario.dev
Datastar: https://data-star.dev

---

🚀 Try it yourself

pip install stario
stario init tiles --template tiles
cd tiles
uv run main.py

---

📚 Covered in this video

Project setup and configuration
RichTracer for development, JsonTracer for production
Static assets with automatic fingerprinting
Handler lifecycle and the Writer pattern
Long-lived SSE connections with w.alive
Background task pattern (no separate concept needed)
HTML generation with stario.html
Datastar attributes and actions
Relay pub/sub for real-time updates

---

#python #webframework #stario #datastar #realtime #sse #tutorial