File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 14
14
def index (request ):
15
15
return web .Response (body = b'<h1>Index</h1>' )
16
16
17
- def hello (request ):
18
- yield from asyncio .sleep (0.5 )
17
+ async def hello (request ):
18
+ await asyncio .sleep (0.5 )
19
19
text = '<h1>hello, %s!</h1>' % request .match_info ['name' ]
20
20
return web .Response (body = text .encode ('utf-8' ))
21
21
22
- @asyncio .coroutine
23
- def init (loop ):
22
+ async def init (loop ):
24
23
app = web .Application (loop = loop )
25
24
app .router .add_route ('GET' , '/' , index )
26
25
app .router .add_route ('GET' , '/hello/{name}' , hello )
27
- srv = yield from loop .create_server (app .make_handler (), '127.0.0.1' , 8000 )
26
+ srv = await loop .create_server (app .make_handler (), '127.0.0.1' , 8000 )
28
27
print ('Server started at http://127.0.0.1:8000...' )
29
28
return srv
30
29
You can’t perform that action at this time.
0 commit comments