API reference¶
The public Python API is intentionally small. Most users only touch the top-level serve() function and a Config instance.
High-performance HTTP/2 ASGI server for FastAPI, Starlette, and similar apps.
h2corn is optimized for h2c behind a trusted reverse proxy, with optional direct TLS support for TCP deployments. Application traffic stays on HTTP/2 end-to-end instead of being downgraded to HTTP/1.1 inside the trust boundary.
The two entrypoints are:
serve— start the server through the multi-worker supervisor (Unix) or in-process (Windows). This matches the behavior of theh2cornCLI.Server— embed a single-worker server in your own event loop.
Configuration is provided through Config, which is also constructable from environment variables or a TOML file.
| Symbol | What it is |
|---|---|
serve | Start the server through the multi-worker supervisor (or in-process on Windows). |
Server | Embed a single-worker server in your own event loop. |
Config | Frozen dataclass holding every server option. |
ProxyProtocolMode | Literal type for the proxy_protocol option. |
ASGIApp | Callable type alias for an ASGI 3 application. |
For per-option descriptions, defaults, environment variables, and CLI flags, see the Configuration reference.