Skip to content

hayatepy/hayate

Repository files navigation

hayate

A web-standards-first Python web framework, inspired by Hono.

hayate (疾風, "swift wind") brings the Fetch API model to Python. Everything you touch maps 1:1 to WHATWG / IETF web standards; Python-local protocols such as WSGI and ASGI are demoted to adapter-level implementation details.

  • Standards-firstRequest / Response / Headers / URL follow WHATWG Fetch and URL semantics. Routing syntax is the WHATWG URLPattern standard (/books/:id), not a custom DSL.
  • Minimal, portable core — one pure-Python Unicode standards dependency; runs anywhere CPython or Pyodide runs.
  • Runtime-agnostic — the app core is a pure fetch(Request) -> Response function. ASGI servers, Cloudflare Python Workers, and AWS Lambda are thin adapters.
  • Async-first, typed — Python 3.12+.

Install

uv add hayate        # or: pip install hayate

Quickstart

from hayate import Hayate, HTTPException

app = Hayate()

@app.get("/books/:id")
async def show_book(c):
    book = BOOKS.get(c.req.param("id"))
    if book is None:
        raise HTTPException(404, title="Book not found")
    return c.json(book)

Run with any ASGI server:

uvicorn main:app

Testing without a server

The app core performs no I/O, so tests call it directly — no test client, no sockets:

async def test_show_book():
    res = await app.request("/books/1")
    assert res.status == 200
    assert (await res.json())["id"] == "1"

Runtime-bound CORS allowlists can inspect the request context:

from hayate.middleware import cors

app = Hayate(env={"CORS_ORIGINS": {"https://app.example.com"}})

def allowed_origin(c, request_origin):
    return request_origin if request_origin in c.env["CORS_ORIGINS"] else None

app.use(cors(origin_resolver=allowed_origin, credentials=True))

Conformance and performance, measured

  • Standards conformance runs against vendored web-platform-tests vectors on every pytest run, with ratcheted pass counts — see docs/conformance.md.
  • Framework overhead is benchmarked against Starlette (1.27x on simple routes, 3.83x at 64 routes; optional Rust accelerator included) — see docs/benchmarks.md.

Status

Alpha (0.10.x): the surface tracks DESIGN.md (Japanese) and may still move before 1.0. Changes are recorded in CHANGELOG.md; platform research lives in docs/research/.

The wider ecosystem adds authentication, MCP, OpenAPI, and a portable client-side fetch. See the hayatepy organization profile for the current compatibility matrix.

License

MIT

About

Web-standards-first Python framework: WHATWG Fetch / URL / URLPattern across ASGI, Cloudflare Workers, and AWS Lambda

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages