aio.web.server
Web server for the aio asyncio framework
Build status
Installation
Requires python >= 3.4
Install with:
pip install aio.web.server
Quick start - Hello world web server
Create a web server that says hello
Save the following into a file "hello.conf"
[aio]
modules = aio.web.server
[server/my_server]
factory = aio.web.server.factory
port = 8080
[web/my_server/my_route]
match = /
route = my_example.handler
And save the following into a file named my_example.py
import aiohttp
import aio.web.server
@aio.web.server.route
def handler(request, config):
return aiohttp.web.Response(body=b"Hello, web world")
Run with the aio run command
aio run -c hello.conf
Web server configuration
Web server definitions are in the following format, where SERVER_NAME corresponds to the server/SERVER_NAME
[web/SERVER_NAME]
So for example you might have the following
[server/my_server]
factory = aio.web.server.factory
port = 8080
[web/my_server]
modules = ${aio:modules}
some.web.module
Route configuration
Route definitions are in defined in sections with the following format
[web/SERVER_NAME/ROUTE_NAME]
So an example server configuation with a route defined for the path / might be
[aio]
modules = aio.web.server
[server/my_server]
factory = aio.web.server.factory
port = 8080
[web/my_server/my_route]
match = /
route = my.route.handler