fix: run_app usage
This commit is contained in:
10
src/api.py
10
src/api.py
@@ -86,7 +86,7 @@ async def attach_db(app: web.Application):
|
|||||||
async def test(request: web.Request) -> web.Response:
|
async def test(request: web.Request) -> web.Response:
|
||||||
return web.Response(text="Hello World")
|
return web.Response(text="Hello World")
|
||||||
|
|
||||||
async def app_factory():
|
def app_factory():
|
||||||
auth = key_auth_factory(conf.API['TOKEN'])
|
auth = key_auth_factory(conf.API['TOKEN'])
|
||||||
app = web.Application(middlewares=[auth])
|
app = web.Application(middlewares=[auth])
|
||||||
app.cleanup_ctx.append(attach_db)
|
app.cleanup_ctx.append(attach_db)
|
||||||
@@ -100,11 +100,7 @@ async def app_factory():
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
async def run_app():
|
if __name__ == '__main__':
|
||||||
app = await app_factory()
|
app = app_factory()
|
||||||
web.run_app(app, port=int(conf.API['PORT']))
|
web.run_app(app, port=int(conf.API['PORT']))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
asyncio.run(run_app())
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user