aiohttp-utils provides handy utilities for building aiohttp.web applications.
- Method-based handlers ("resources")
- Routing utilities
- Content negotiation with JSON rendering by default
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
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
}
)
$ pip install aiohttp-utils
Full documentation is available at https://aiohttp-utils.readthedocs.io/.
- Docs: https://aiohttp-utils.readthedocs.io/
- Changelog: https://aiohttp-utils.readthedocs.io/en/latest/changelog.html
- PyPI: https://pypi.python.org/pypi/aiohttp-utils
- Issues: https://github.com/sloria/aiohttp-utils/issues
MIT licensed. See the bundled LICENSE file for more details.