Examples¶
End-to-end, runnable examples organized by feature area. Each example is self-contained and can be lifted into a fresh project.
REST¶
REST CRUD with validation —
GET/POST/PUT/DELETEon a single resource, withinject(...)validation andNotFoundResponseDirectivefor404.
HTML¶
HTML form: GET the form, POST it, redirect on success — render a Jinja2 form, validate submission, emit
RedirectResponseDirectiveon success.
WebSocket¶
Asynchronous File Processing with WebSocket Feedback (Ticket Pattern) — REST upload + WebSocket progress events, avoiding the subscribe-after-upload race.
Middleware¶
Middleware: Token authentication end-to-end — protect REST endpoints with a Bearer-token middleware and event inheritance, returning
401for unauthenticated requests.Middleware: deferred (async) authentication with replace_event + redirect_event — gate REST/WebSocket events behind an async token check using
replace_event+redirect_event+register_events, validated by a separate auth component.Middleware: per-stage latency as a Server-Timing header — a response middleware that publishes
event._timingas a standardServer-Timingheader, so DevTools shows where each request spent its time.
Worker¶
Offloading CPU-bound work to a WorkerProcess — offload heavy computation off the manager thread.
SharedMemoryPipe: streaming a ZIP of a folder — high-throughput on-the-fly downloads.
Streaming an upload straight into MinIO / S3 — forward an HTTP upload straight into object storage via
SharedMemoryPipe, with no buffering and end-to-end backpressure.Scatter–gather (fan-out / fan-in) with resolve_callback_worker — answer one request by fanning it out to many workers and aggregating the parts in
resolve_callback_worker.
Scheduler + Key-Value Store¶
Periodic refresh into the Key-Value Store — Scheduler ticks update a cached snapshot held in the KV Store; readers fetch via
Get.
Pydantic AI¶
Pydantic AI: a support agent with tools that dispatch to a different Manager — an agent's tools call Events handled by a separate Manager's Worker, with two tools called in parallel in the same turn.
If you're new to EDRI, the REST CRUD with validation is the shortest end-to-end demonstration.