Issue
I have an asyncio app and I want to add a simple REST API to it using aiohttp. As far as I can see, I can either create an aiohttp app and run it with aiohttp.web.run_app
on another thread, or I'd have to forget about the app and use the lower level aiohttp.web.Server
API. Is there a way I can use aiohttp.web.Application
and then run the web application as a coroutine instead of using run_app
?
Solution
Just open sourced code for aiohttp.web:run_app
(https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web.py#L413-L467) and see how it's implemented.
You could do the same but don't call blocking loop.run_forever()
.
Answered By - Andrew Svetlov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.