Single-file apps (pip evaluators)¶
Run these without cloning the monorepo. Requires Python 3.11+ and a working network for
pip install.
Try it (simulated)¶
Docs simulation — click Refresh status for an HTMX-style fragment swap (no server).
127.0.0.1:8000 — click Refresh status for an HTMX-style fragment swap (no server).What hedron new writes as app.py (the real app, not the docs simulator):
app.py
import os
from datetime import UTC, datetime
from hedron import Hedron, Page, RefreshButton, Stack, Text, html, swap
app = Hedron(
title="Hedron App",
security="standard",
explorer="off",
session_secret=os.environ.get("HEDRON_SESSION_SECRET", "replace-in-production"),
)
status = app.region("service-status", description="Live status panel")
def status_panel():
stamp = datetime.now(UTC).strftime("%H:%M:%S UTC")
return html.div(
Text(f"All systems operational · refreshed {stamp}"),
id=status.id,
role="status",
aria={"live": "polite"},
)
@app.page("/")
def home() -> Page:
return Page(
Stack(
Text("Hello from hedron new"),
status_panel(),
RefreshButton.for_region(status, href="/status", label="Refresh status"),
),
title="Home",
)
@app.fragment("/status", region=status)
def refresh_status():
return swap(status_panel())
Hello page¶
Static Hello only
This sample has no Refresh / HTMX. Prefer
Build your first app (hedron new) for the
interactive first-hour experience.
Save as app.py:
from hedron import Hedron, Page, Text
app = Hedron(title="Demo", security="standard", session_secret="replace-me")
@app.page("/")
def home() -> Page:
return Page(Text("Hello, Hedron"), title="Demo")
Open http://127.0.0.1:8000.
CSRF form¶
Follow the pasteable app in Minimal form POST.
Live clock (polling)¶
Follow the pasteable app in Live interaction (“poll a clock”).
When you need the monorepo¶
Clone for Flask/Django reference apps, the team-admin reference app, and HDJ progressive examples: Runnable examples.