Discuss / Python / 楼下正解,教材已经过时了,大家看看aiohttp的官方例子吧

楼下正解,教材已经过时了,大家看看aiohttp的官方例子吧

Topic source

叫是先生

#2 Created at ... [Delete] [Delete and Lock User]

我重新修正了下。。效果是一样的

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

Reply