Minimal async web framework, built on aiohttp.


License
BSD-3-Clause
Install
pip install ponty==0.3.5

Documentation

Ponty: async HTTP server for Python

Ponty is a simple wrapper on aiohttp. It is primarily oriented around building JSON APIs.

Latest PyPI package version Latest Read The Docs Downloads count

Documentation

https://ponty.readthedocs.io/

Getting Started

Hello World

from ponty import (
    expect,
    get,
    render_json,
    Request,
    startmeup,
    StringRouteParameter,
)


class Req(Request):

    name = StringRouteParameter()


@get(f"/hello/{Req.name}")
@expect(Req)
@render_json
async def handler(name: str):
    return {"greeting": f"hello {name}!"}


if __name__ == "__main__":
    startmeup(port=8080)
$ curl localhost:8080/hello/you -v | python -m json.tool
> GET /hello/you HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Content-Length: 72
< Date: Tue, 02 Aug 2022 13:53:11 GMT
< Server: Python/3.9 aiohttp/3.7.3
<
{
    "data": {
        "greeting": "hello you!"
    },
    "elapsed": 0,
    "now": 1659448391571
}

Requirements