update
This commit is contained in:
36
backend/base/app.py
Normal file
36
backend/base/app.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from api.profile_controller import router as profiles_router
|
||||
from api.video_controller import router as videos_router
|
||||
from database.database import SessionLocal, create_tables
|
||||
from model.profile import Profile
|
||||
from notify.notify_clients import register_websocket
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(videos_router)
|
||||
app.include_router(profiles_router)
|
||||
register_websocket(app)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def startup():
|
||||
create_tables()
|
||||
db = SessionLocal()
|
||||
if db.query(Profile).count() == 0:
|
||||
db.add(Profile(name="Standard"))
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"status": "running"}
|
||||
Reference in New Issue
Block a user