Handy utilities for aiohttp.web applications.
Project description
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
}
)
Install
$ pip install aiohttp-utils
Documentation
Full documentation is available at https://aiohttp-utils.readthedocs.io/.
Project Links
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-3.2.1.tar.gz
(20.1 kB
view hashes)
Built Distribution
Close
Hashes for aiohttp_utils-3.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea1d6e20c6c29062ba6bffbd8aa8cb852dbf0403499908c473f3932c0d7877b |
|
MD5 | 37cd80499010713205511c12f1058b55 |
|
BLAKE2b-256 | 0669cdae27ac34ccb3d0616f963ab03159e2e59b21e62ae3d08bfc171f48683b |