#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'Michael Liao'

'''
async web application.
'''

import logging; logging.basicConfig(level=logging.INFO)

import asyncio, os, json, time
from datetime import datetime

from aiohttp import web

def index(request):
    return web.Response(body=b'<h1>Awesome</h1>')

async def init(loop):
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', index)
    srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv

loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()

[((125, 164), 'logging.basicConfig', 'logging.basicConfig', ([], {'level': 'logging.INFO'}), '(level=logging.INFO)\n', (144, 164), False, 'import logging\n'), ((587, 611), 'asyncio.get_event_loop', 'asyncio.get_event_loop', ([], {}), '()\n', (609, 611), False, 'import asyncio, os, json, time\n'), ((284, 322), 'aiohttp.web.Response', 'web.Response', ([], {'body': "b'<h1>Awesome</h1>'"}), "(body=b'<h1>Awesome</h1>')\n", (296, 322), False, 'from aiohttp import web\n'), ((356, 382), 'aiohttp.web.Application', 'web.Application', ([], {'loop': 'loop'}), '(loop=loop)\n', (371, 382), False, 'from aiohttp import web\n'), ((505, 563), 'logging.info', 'logging.info', (['"""server started at http://127.0.0.1:9000..."""'], {}), "('server started at http://127.0.0.1:9000...')\n", (517, 563), False, 'import logging\n')]