Skip to main content

minihttp

minihttp is a small production ready HTTP server that implements subset of the HTTP protocol. For example, it only supports GET and POST and always closes the connection.

Path parameters are bound by name. A handler may define one request-data argument: for GET requests the entire query string is deserialized into that argument's annotated type, and for POST requests the entire JSON body is deserialized into it. A handler may also define one argument annotated as Headers, which receives the request headers with case-insensitive lookups.

Usage

from dataclasses import dataclass

from minihttp import Headers, Server


@dataclass
class UserQuery:
    sort_by: str


@dataclass
class Group:
    name: str
    active: bool = True


server = Server()


@server.get("/groups/:group_id")
def users(group_id: int, query: UserQuery, headers: Headers):
    # GET /groups/7?sort_by=name turns the query string into
    # UserQuery(sort_by="name"). Header lookup is case-insensitive.
    request_id = headers.get("X-Request-ID")
    return [group_id, query.sort_by, request_id]


@server.post("/groups/new")
def new_group(group: Group):
    # A JSON body such as {"name":"admins","active":false} is
    # deserialized directly into Group("admins", False).
    return group


server.run("0.0.0.0", 2000)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minihttp-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minihttp-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file minihttp-0.1.0.tar.gz.

File metadata

  • Download URL: minihttp-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for minihttp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a8b19ba6d40dd3c96df3f3260f2edd9efcd9eef0ddaebd9c20b2936b2b142a3
MD5 785be2d77aedfea3e322251077b08d17
BLAKE2b-256 31882ec7c62963bbf721c7044880de7e8e875935312f5ef081366b826c8c3e0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for minihttp-0.1.0.tar.gz:

Publisher: publish.yml on mizuki-hikaru/minihttp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minihttp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: minihttp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for minihttp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4c08d94594785bb8257d13f169a8826853059d4009fe7700185529897ec5c7
MD5 6fb34f428beb251fef741f963dfda4db
BLAKE2b-256 09f45a11913cab7768f595a30b0cd5add20ac04b329bb7625065b719b44f9a42

See more details on using hashes here.

Provenance

The following attestation bundles were made for minihttp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mizuki-hikaru/minihttp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page