楼下正解,教材已经过时了,大家看看aiohttp的官方例子吧
Topic source我重新修正了下。。效果是一样的
async def index(request):
return web.Response(body='<h1>Index</h1>'.encode(), content_type='text/html')
async def init(loop):
app = web.Application()
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
- 1
叫是先生
https://aiohttp.readthedocs.io/en/stable/web_quickstart.html#run-a-simple-web-server
这是链接