Handy utilities for aiohttp.web applications.
Project description
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/.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohttp_utils-2.0.0.tar.gz.
File metadata
- Download URL: aiohttp_utils-2.0.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80b358e6209248031e3b7917d25065f0c94f42d1d11b2a6bf67daa8757f33da1
|
|
| MD5 |
255a348a7b3709502d025ef3afd15b95
|
|
| BLAKE2b-256 |
ab2eb34ce5df91811489ad44fa56e5ac0e3ae2785c811b2ab1d4d4bb839576c3
|
File details
Details for the file aiohttp_utils-2.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: aiohttp_utils-2.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aada28d32436d38a320f587fbb775b43b830ae187dcffd73e35eec5fcc061c1
|
|
| MD5 |
8965a6aafd0d361042e50f41853505d1
|
|
| BLAKE2b-256 |
c001fbfdd0713a0f6bd5bca2614296519bbdb92ae1f66ac88b9beed7cd9d565d
|