http_charfinder.py with async/await

This commit is contained in:
Luciano Ramalho 2015-07-13 23:12:24 -03:00
parent aeee41988e
commit e43f65c9c8
2 changed files with 3 additions and 3 deletions

1
18b-async-await/charfinder/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
charfinder_index.pickle

View File

@ -45,12 +45,11 @@ def home(request): # <1>
# BEGIN HTTP_CHARFINDER_SETUP
@asyncio.coroutine
def init(loop, address, port): # <1>
async def init(loop, address, port): # <1>
app = web.Application(loop=loop) # <2>
app.router.add_route('GET', '/', home) # <3>
handler = app.make_handler() # <4>
server = yield from loop.create_server(handler,
server = await loop.create_server(handler,
address, port) # <5>
return server.sockets[0].getsockname() # <6>