aio.http.server

HTTP server for the aio asyncio framework


License
GPL-2.0+
Install
pip install aio.http.server==0.1.4

Documentation

aio.http.server

HTTP server for the aio asyncio framework

Build status

https://travis-ci.org/phlax/aio.http.server.svg?branch=master

Installation

Requires python >= 3.4

Install with:

pip install aio.http.server

Quick start - Hello world http server

Create a web server that says hello

Save the following into a file "hello.conf"

[server/my_server]
factory = aio.http.server.factory
port = 8080
protocol = my_example.protocol

And save the following into a file named my_example.py

import asyncio
import aiohttp

import aio.app

@aio.app.server.protocol
def protocol(name):
    loop = asyncio.get_event_loop()
    webapp = aiohttp.web.Application(loop=loop)

    @asyncio.coroutine
    def handle_hello_world(webapp):
        return aiohttp.web.Response(body=b"Hello, world")

    webapp.router.add_route("GET", "/", handle_hello_world)
    return webapp.make_handler()

Run with the aio run command

aio run -c hello.conf