feature gunicorn startup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
import uvicorn
|
||||
# import uvicorn
|
||||
from fastapi import FastAPI
|
||||
|
||||
from src.web.protected_routes.auth_routes import router as protected_router
|
||||
@@ -8,7 +9,15 @@ from src.web.protected_routes.protected_user_action_routes import (
|
||||
router as protected_user_action_routes,
|
||||
)
|
||||
|
||||
app=FastAPI(root_path="/")
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
create_dirs()
|
||||
yield
|
||||
print("shutting down")
|
||||
|
||||
|
||||
app=FastAPI(root_path="/", lifespan=lifespan)
|
||||
app.include_router(router=protected_router)
|
||||
app.include_router(router=protected_user_action_routes)
|
||||
|
||||
@@ -26,11 +35,4 @@ def create_dirs():
|
||||
"./upload_finished")
|
||||
|
||||
for x in dirs_to_create:
|
||||
Path(x).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def main():
|
||||
create_dirs()
|
||||
uvicorn.run("main:app", host="0.0.0.0", reload=True)
|
||||
|
||||
if __name__=="__main__":
|
||||
main()
|
||||
Path(x).mkdir(parents=True, exist_ok=True)
|
||||
Reference in New Issue
Block a user