We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac5faaf commit 9e84c9bCopy full SHA for 9e84c9b
1 file changed
samples/async/aio_web.py
@@ -14,17 +14,16 @@
14
def index(request):
15
return web.Response(body=b'<h1>Index</h1>')
16
17
-def hello(request):
18
- yield from asyncio.sleep(0.5)
+async def hello(request):
+ await asyncio.sleep(0.5)
19
text = '<h1>hello, %s!</h1>' % request.match_info['name']
20
return web.Response(body=text.encode('utf-8'))
21
22
-@asyncio.coroutine
23
-def init(loop):
+async def init(loop):
24
app = web.Application(loop=loop)
25
app.router.add_route('GET', '/', index)
26
app.router.add_route('GET', '/hello/{name}', hello)
27
- srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 8000)
+ srv = await loop.create_server(app.make_handler(), '127.0.0.1', 8000)
28
print('Server started at http://127.0.0.1:8000...')
29
return srv
30
0 commit comments