This project has been archived by its maintainers, and is no longer receiving any updates.
JSON REST framework based on aiohttp (an asyncio (PEP 3156) http server).
aiorest development has stopped
The project always was in experimental status: we have tried to make the proof of concept for aiohttp high level server.
Now the work is done, the most important parts transplanted to aiohttp.web: Request and Response.
Some aiorest features are not supported by aiohttp.web yet: sessions, CORS and security.
We are working hard on the issue by making aiohttp extension libraries for those ones.
We will keep aiorest work on top of aiohttp new versions for a while.
Please report about incompatibility bugs to aiorest github issue tracker – we’ll fix those.
Example usage
Simple REST server can be run like this:
import asyncio
import aiohttp
import aiorest
# define a simple request handler
# which accept no arguments
# and responds with json
def hello(request):
return {'hello': 'world'}
loop = asyncio.get_event_loop()
server = aiorest.RESTServer(hostname='127.0.0.1',
loop=loop)
# configure routes
server.add_url('GET', '/hello', hello)
# create server
srv = loop.run_until_complete(loop.create_server(
server.make_handler, '127.0.0.1', 8080))
@asyncio.coroutine
def query():
resp = yield from aiohttp.request(
'GET', 'http://127.0.0.1:8080/hello', loop=loop)
data = yield from resp.read_and_close(decode=True)
print(data)
loop.run_until_complete(query())
srv.close()
loop.run_until_complete(srv.wait_closed())
loop.close()
this will print {'hello': 'world'} json
See examples for more.
Requirements
Python 3.3
asyncio http://code.google.com/p/tulip/ or Python 3.4+
optional module aiorest.redis_session requires aioredis https://github.com/aio-libs/aioredis
License
aiorest is offered under the MIT license.
CHANGES
0.4.0 (2015-01-18)
The aiorest library development has stopped, use aiohttp.web instead.
Update aiorest code to be compatible with aiohttp 0.14 release.
0.3.1 (2014-12-22)
Fixed exceptions logging for unhandled errors
0.3.0 (2014-12-17)
Made aiorest compatible to aiohttp v0.12
0.2.5 (2014-10-30)
Fix response.write_eof() to follow aiohttp changes
0.2.4 (2014-09-12)
Make loop keywork-only parameter in create_session_factory() function
0.2.3 (2014-08-28)
Redis session switched from asyncio_redis to aioredis
0.2.2 (2014-08-15)
Added Pyramid-like matchdict to request (see https://github.com/aio-libs/aiorest/pull/18)
Return “400 Bad Request” for incorrect JSON body in POST/PUT methods
README fixed
Custom response status code (see https://github.com/aio-libs/aiorest/pull/23)
0.1.1 (2014-07-09)
Switched to aiohttp v0.9.0
0.1.0 (2014-07-07)
Basic REST API
Release files for aiorest 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiorest-0.4.0.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiorest-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.5 kB
Release files / aiorest-0.4.0.tar.gz
| Download URL | aiorest-0.4.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f50197355aa74bc7f4b56a84d1b249fa3514be78aa519299f6ae53e3b26c99e4
|
|
BLAKE2b-256 checksum How to use checksums |
642133d3b96412c3c9c437ae769e560ffa689890b541a1216fa117dbd7596d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / aiorest-0.4.0-py3-none-any.whl
| Download URL | aiorest-0.4.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78f6d7d6ca2c350332bdbdc311d99210457011abadd70b8e33aa82b7df84ba19
|
|
BLAKE2b-256 checksum How to use checksums |
904bd15fe6d53979f0d326160174ac88cc1510f526e17843d5cf83bfa76c24a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |