Skip to main content

Support REST calls for asyncio+aiohttp.

Project description

JSON REST framework based on aiohttp (an asyncio (PEP 3156) http server).

https://travis-ci.org/aio-libs/aiorest.svg?branch=master

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():
    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

License

aiorest is offered under the MIT license.

CHANGES

0.1.1 (2014-07-09)

  • Switched to aiohttp v0.9.0

0.1.0 (2014-07-07)

  • Basic REST API

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

aiorest-0.2.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

aiorest-0.2.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file aiorest-0.2.0.tar.gz.

File metadata

  • Download URL: aiorest-0.2.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiorest-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c4fc2e7e13db2e2a3e2aee3c559c8ea4bca26611f76902cdeae530a6ea69cb0d
MD5 41e4f2572bc39d62242d1cb3d94b9276
BLAKE2b-256 7c559df0525affd7de8639987e449adea45ba8a97b922f4ad33eec85144e5ada

See more details on using hashes here.

Provenance

File details

Details for the file aiorest-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiorest-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 832f695085cdc0b28151ee2bea442d87768a584d8cecc0b98786ca93448f65db
MD5 f90d89313aec365ef9d861a88638ea56
BLAKE2b-256 9bcd1d9e5eb069bc8d8541192d6a8d724090287f175418072dd1f34701caba05

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