Skip to main content

Handy utilities for aiohttp.web applications.

Project description

Latest version Travis-CI

aiohttp_utils provides handy utilities for building aiohttp.web applications.

  • Method-based handlers (“resources”)

  • Content negotiation with JSON rendering by default

  • Local development server with auto-reloading

  • And more

Everything is optional. You can use as much (or as little) of this toolkit as you need.

from aiohttp import web
from aiohttp_utils import Response, routing, negotiation, run

app = web.Application(router=routing.ResourceRouter())

# Method-based handlers
class HelloResource:

    async def get(self, request):
        name = request.GET.get('name', 'World')
        return Response({
            'message': 'Hello ' + name
        })


app.router.add_resource_object('/', HelloResource())

# Content negotiation
negotiation.setup(
    app, renderers={
        'application/json': negotiation.render_json
    }
)

if __name__ == '__main__':
    # Development server
    run(
        app,
        app_uri='hello.app:app',
        reload=True,
        port=8000
    )

Install

$ pip install aiohttp_utils

Documentation

Full documentation is available at https://aiohttp-utils.readthedocs.org/.

License

MIT licensed. See the bundled LICENSE file for more details.

Project details


Download files

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

Source Distribution

aiohttp_utils-2.0.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

aiohttp_utils-2.0.1-py2.py3-none-any.whl (14.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file aiohttp_utils-2.0.1.tar.gz.

File metadata

File hashes

Hashes for aiohttp_utils-2.0.1.tar.gz
Algorithm Hash digest
SHA256 a0ae4d033844d97780ba030ccc15f66464fb338dfb291fa6e2c42327bd11d1af
MD5 7dac4773822ec9cf82e3f3a1532bb041
BLAKE2b-256 0b16b19e7b5aebccd9aef5e34a60f78d459b165c2e02902b71aef365a816f837

See more details on using hashes here.

Provenance

File details

Details for the file aiohttp_utils-2.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aiohttp_utils-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 750667a63fb1deac57566068e05049ce29a76f4e019c9126475c109eabee95ac
MD5 fcff58b664cfcbcf953041b1532d20eb
BLAKE2b-256 89759ed678ac72a8972d2dacdd0fbd4bf266d0fd72f6bd86f5c1f8e9937ac05a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page