This release is a pre-release and may not be stable for production use.
aiohug
Tasks:
Unpack aiohttp request to arguments with annotations
Validate handlers arguments
Generate swagger specification
Examples
Run ping pong application
from aiohttp import web
from aiohug import RouteTableDef
routes = RouteTableDef()
@routes.get("/ping/")
async def ping():
return "pong"
app = web.Application()
app.add_routes(routes)
if __name__ == "__main__":
web.run_app(app)
There is no more request object in handler.
Arguments from path and query
@routes.get("/hello/{name}/")
async def hello(name: fields.String(), greeting: fields.String() = "Hello"):
return {"msg": f"{greeting}, {name}"}
Body with schema
from aiohttp import web
from aiohug import RouteTableDef
routes = RouteTableDef()
class PayloadSchema(Schema):
count = fields.Int()
@routes.get("/")
async def with_body(body: PayloadSchema()):
return body
app = create_app()
app.add_routes(routes)
client = await test_client(app)
resp = await client.get("/", json={"count": "5", "another": 7})
assert await resp.json() == {"count": 5}
Another shortcuts
@routes.post("/ping/")
async def ping():
return 201, "pong"
Why aiohug?
It’s just hug API implementation for aiohttp
TODO:
don’t pass default arguments
default websocket handler with ping/pong and schemas support
ws = aiohug.WSHandler()
@ws("hello") # match message by `type` field
async def hello(name: str, greeting: str="Hi"):
""" Just send {"type": "hello", "name": "Lucy", "greeting": "Hi"} """
return {"text", f"{greeting}, {name}"}
app = create_app()
app.add_routes([web.get('/ws', ws)])
Metadata
Release files for aiohug 0.3.2.dev29217850
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 |
|---|---|---|---|---|
| aiohug-0.3.2.dev29217850.tar.gz | 9.6 kB | Without provenance | Details for aiohug-0.3.2.dev29217850.tar.gz |
Release files / aiohug-0.3.2.dev29217850.tar.gz
| Download URL | aiohug-0.3.2.dev29217850.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b93abbeae60aa58943b5154194d5c4641042f79836644b804750d179b605cffb
|
|
BLAKE2b-256 checksum How to use checksums |
6fe59afdb3d5e5bc95d1ca4edda5c47bf24a8143d5c19252ffe6a8db527ec736
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
|
Security for aiohug 0.3.2.dev29217850
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.