The frozen dataclass that controls all server behavior
8 min read1544 words
Overview
ServerConfig is a frozen dataclass (@dataclass(frozen=True, slots=True)) that holds all server settings. It's created once at startup and shared across all workers — safe because it's immutable.
InjectServer-Timingheader with parse/app/encode durations
health_check_path
str | None
None
Path for built-in health endpoint (e.g."/health"). Disabled by default.
Note
Request IDs are always generated (or extracted from trusted proxies). Every response includes anX-Request-ID header for tracing, and requests from trusted proxies that send X-Request-IDhave their IDs honoured.
Development
Field
Type
Default
Description
debug
bool
False
Enable rich error pages (never use in production)
reload
bool
False
Watch source files and restart workers on changes
reload_include
tuple[str, ...]
()
Extra file extensions to watch (e.g.(".html", ".css", ".md"))
reload_dirs
tuple[str, ...]
()
Extra directories to watch alongside the current working directory
Trusted proxy hosts for X-Forwarded-* header validation (empty = strip all proxy headers). Accepts any iterable; normalized to frozenset internally.
Note
Whentrusted_hosts is empty, Pounce strips X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Host from all requests. Set it to your reverse proxy's IP (e.g. frozenset({"10.0.0.1"})) or frozenset({"*"})to trust all peers. Tuples and lists are also accepted and converted automatically.
TLS
Field
Type
Default
Description
ssl_certfile
str | None
None
Path to TLS certificate file
ssl_keyfile
str | None
None
Path to TLS private key file
Note
ssl_certfile and ssl_keyfile must both be set or both be None. Setting only one raises ValueError.
Extended Fields
These fields control optional features. Most have sensible defaults and don't need to be set for basic usage.
Static Files
Field
Type
Default
Description
static_files
dict[str, str]
{}
URL path to directory mapping (e.g.{"/static": "./public"})
static_cache_control
str
"public, max-age=3600"
Cache-Control header for static files
static_precompressed
bool
True
Serve.zst/.gzpre-compressed variants when available
static_follow_symlinks
bool
False
Allow following symlinks (keep disabled in production)