Skip to content

Runnable examples

The repository ships three examples that progress across the current public surface. Clone the repository and prepare its development environment:

Terminal window
git clone https://github.com/tugrulguner/dexpot.git
cd dexpot
uv sync --all-extras

examples/minimal.py demonstrates a typed integer path capture and msgspec response.

Terminal window
uv run python examples/minimal.py
curl -s http://127.0.0.1:8000/items/7
{"id":7,"name":"item-7","price":7.0}

examples/typed_crud.py demonstrates typed JSON bodies, compiled response encoders, status/payload returns, and thread-safe shared application state.

Terminal window
uv run python examples/typed_crud.py
curl -s -X POST http://127.0.0.1:8000/items \
-H 'Content-Type: application/json' \
-d '{"name":"keyboard","price":79.0}'

The lock in this example belongs to the application. It protects the mutable dictionary when handlers execute concurrently.

examples/bounded_api.py customizes HttpLimits and exercises 413, 422, and 405 responses plus typed Request injection.

Terminal window
uv run python examples/bounded_api.py
curl -s http://127.0.0.1:8000/health
curl -s http://127.0.0.1:8000/context

The test suite launches every example as a subprocess and validates its public HTTP behavior. Set DEXPOT_EXAMPLE_PORT when port 8000 is occupied.

Read the complete examples guide and source files in the repository.