http_charfinder.py with async/await
This commit is contained in:
parent
aeee41988e
commit
e43f65c9c8
1
18b-async-await/charfinder/.gitignore
vendored
Normal file
1
18b-async-await/charfinder/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
charfinder_index.pickle
|
@ -45,12 +45,11 @@ def home(request): # <1>
|
|||||||
|
|
||||||
|
|
||||||
# BEGIN HTTP_CHARFINDER_SETUP
|
# BEGIN HTTP_CHARFINDER_SETUP
|
||||||
@asyncio.coroutine
|
async def init(loop, address, port): # <1>
|
||||||
def init(loop, address, port): # <1>
|
|
||||||
app = web.Application(loop=loop) # <2>
|
app = web.Application(loop=loop) # <2>
|
||||||
app.router.add_route('GET', '/', home) # <3>
|
app.router.add_route('GET', '/', home) # <3>
|
||||||
handler = app.make_handler() # <4>
|
handler = app.make_handler() # <4>
|
||||||
server = yield from loop.create_server(handler,
|
server = await loop.create_server(handler,
|
||||||
address, port) # <5>
|
address, port) # <5>
|
||||||
return server.sockets[0].getsockname() # <6>
|
return server.sockets[0].getsockname() # <6>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user