# app.py
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.Respnse(body=b'<h1>Hello,wolrd. I am Henry.</h1>', content_type='text/html')
@asyncio.coroutine
def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/', index)
srv = yield from 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()
在Linux命令行中输入:
$ python3 app.py
浏览器报错:
【500 Internal Server Error
Server got itself in trouble】
命令行的全部报错信息: