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:
|
||||
return web.Response(text="Hello World")
|
||||
|
||||
async def app_factory():
|
||||
def app_factory():
|
||||
auth = key_auth_factory(conf.API['TOKEN'])
|
||||
app = web.Application(middlewares=[auth])
|
||||
app.cleanup_ctx.append(attach_db)
|
||||
@@ -100,11 +100,7 @@ async def app_factory():
|
||||
return app
|
||||
|
||||
|
||||
async def run_app():
|
||||
app = await app_factory()
|
||||
if __name__ == '__main__':
|
||||
app = app_factory()
|
||||
web.run_app(app, port=int(conf.API['PORT']))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(run_app())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user