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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8b19ba6d40dd3c96df3f3260f2edd9efcd9eef0ddaebd9c20b2936b2b142a3
|
|
| MD5 |
785be2d77aedfea3e322251077b08d17
|
|
| BLAKE2b-256 |
31882ec7c62963bbf721c7044880de7e8e875935312f5ef081366b826c8c3e0e
|
Provenance
The following attestation bundles were made for minihttp-0.1.0.tar.gz:
Publisher:
publish.yml on mizuki-hikaru/minihttp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minihttp-0.1.0.tar.gz -
Subject digest:
0a8b19ba6d40dd3c96df3f3260f2edd9efcd9eef0ddaebd9c20b2936b2b142a3 - Sigstore transparency entry: 2617679486
- Sigstore integration time:
-
Permalink:
mizuki-hikaru/minihttp@e903ef7f8a4734bb0530bc36674203eb1efde42e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mizuki-hikaru
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e903ef7f8a4734bb0530bc36674203eb1efde42e -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4c08d94594785bb8257d13f169a8826853059d4009fe7700185529897ec5c7
|
|
| MD5 |
6fb34f428beb251fef741f963dfda4db
|
|
| BLAKE2b-256 |
09f45a11913cab7768f595a30b0cd5add20ac04b329bb7625065b719b44f9a42
|
Provenance
The following attestation bundles were made for minihttp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mizuki-hikaru/minihttp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minihttp-0.1.0-py3-none-any.whl -
Subject digest:
1d4c08d94594785bb8257d13f169a8826853059d4009fe7700185529897ec5c7 - Sigstore transparency entry: 2617679500
- Sigstore integration time:
-
Permalink:
mizuki-hikaru/minihttp@e903ef7f8a4734bb0530bc36674203eb1efde42e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mizuki-hikaru
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e903ef7f8a4734bb0530bc36674203eb1efde42e -
Trigger Event:
push
-
Statement type: