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 the toolkit as you need.

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

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('/', HelloResource())

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

if __name__ == '__main__':
    # Development server
    runner.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-0.1.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

aiohttp_utils-0.1.0-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for aiohttp_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d765b9814abe168babc13d254e54f8499e420120e65dd50a1cbfdf1ef016bda
MD5 692bab6d3dba1a4079bdf7b290e94447
BLAKE2b-256 ec324c88302d6cd36dba1cecc744dad9f604c5c52890e81816cbd1ba952111c9

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for aiohttp_utils-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d9c01d936a02445a09765183ca3efd608a417c03a8fec7c17b3aa67a8cf0dab1
MD5 510ae3546fdab602338cf2d7617aeea0
BLAKE2b-256 bbfa92216dac090dd8319b2902b3948191b73b0310a4b5f2b691cb022efa84d6

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