govyn
A tiny framework for writing async HTTP APIs in typed Python.
govyn (verb) - ask, inquire, query, question, request (Cornish Dictionary)
Features
- Async everywhere!
- Method params as query string arguments
- Dataclasses as request bodies
- Authentication with principals and privileges
- OpenAPI support with built-in routes:
/openapi/schema: OpenAPI v3 schema as JSON/openapi/swagger: embedded Swagger UI page for testing/openapi/redoc: embedded Redoc documentation page
- Prometheus metrics support
Example
from dataclasses import dataclass
from typing import List
from govyn import run
@dataclass
class AddRequest:
numbers: List[int]
@dataclass
class Response:
result: int
class CalculatorAPI:
# run initialisation tasks, e.g. connecting to a database
async def startup(self) -> None:
pass
# be a good citizen and dispose of things appropriately
async def shutdown(self) -> None:
pass
# get_ methods take a query string
# callers will receive a 400 Bad Request if they supply invalid values
async def get_add(self, a: int, b: int) -> Response:
return Response(a + b)
# post_ methods take a JSON request body
# also type-checked according to the dataclass definition
async def post_add(self, req: AddRequest) -> Response:
return Response(sum(req.numbers))
run(CalculatorAPI())
Try out the built-in Swagger UI on this example Heroku deployment, built from source available in the govyn-demo repository!
Or, run the server locally and hit it with curl:
> curl "http://localhost/add?a=10&b=32"
{"result": 42}
> curl "http://localhost/add" -d '{ "numbers": [ 1000, 300, 30, 7 ] }'
{"result": 1337}
Installation
# from PyPI
pip install govyn
# or directly from Git
pip install git+ssh://git@github.com/returnString/govyn.git
Metadata
Release files for govyn 0.19.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| govyn-0.19.0.tar.gz | 10.7 kB | Without provenance | Details for govyn-0.19.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| govyn-0.19.0-py3-none-any.whl | Python 3 | none | any | Details for govyn-0.19.0-py3-none-any.whl |
Total release size: 23.1 kB
Release files / govyn-0.19.0.tar.gz
| Download URL | govyn-0.19.0.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e19119b47952eb740a7c7790d6f62255748dc924e450feea4450908c63a1b96
|
|
BLAKE2b-256 checksum How to use checksums |
6ce018767bfea78b00808afee2ed496bc700c94a275031fd10fa9b22519e036e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / govyn-0.19.0-py3-none-any.whl
| Download URL | govyn-0.19.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d32c14b291df2b26fee94e75de0ab4da785ad14bea8b24461b2de8431ef2b86b
|
|
BLAKE2b-256 checksum How to use checksums |
8df5d62d7776d4bc920ca3b8471b613fe73df1d65f14b6292fd6e92cb194388f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for govyn 0.19.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.