Update App/app.py
Browse files- App/app.py +10 -5
App/app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from fastapi import FastAPI, BackgroundTasks
|
|
|
2 |
from .Editor.editorRoutes import videditor_router
|
3 |
from App import bot
|
4 |
from App.utilis import WorkerClient, SERVER_STATE
|
@@ -9,12 +10,9 @@ from .Generate.generatorRoutes import (
|
|
9 |
)
|
10 |
import uuid
|
11 |
|
12 |
-
app = FastAPI()
|
13 |
-
manager = WorkerClient()
|
14 |
-
|
15 |
|
16 |
-
@
|
17 |
-
async def
|
18 |
app.state.db = database
|
19 |
app.state.models = models
|
20 |
|
@@ -40,6 +38,13 @@ async def startup_event():
|
|
40 |
# print("Error registering worker")
|
41 |
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
@app.get("/")
|
44 |
def read_root():
|
45 |
return {"Hello": "World"}
|
|
|
1 |
from fastapi import FastAPI, BackgroundTasks
|
2 |
+
from contextlib import asynccontextmanager
|
3 |
from .Editor.editorRoutes import videditor_router
|
4 |
from App import bot
|
5 |
from App.utilis import WorkerClient, SERVER_STATE
|
|
|
10 |
)
|
11 |
import uuid
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
+
@asynccontextmanager
|
15 |
+
async def lifespan(app: FastAPI):
|
16 |
app.state.db = database
|
17 |
app.state.models = models
|
18 |
|
|
|
38 |
# print("Error registering worker")
|
39 |
|
40 |
|
41 |
+
app = FastAPI(lifespan=lifespan)
|
42 |
+
manager = WorkerClient()
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
@app.get("/")
|
49 |
def read_root():
|
50 |
return {"Hello": "World"}
|