tranny / App /app.py
bla's picture
Update App/app.py
bc45051
raw
history blame
1.09 kB
from fastapi import FastAPI
from .Users.UserRoutes import user_router
from .modelInit import models, database
from .Transcription.TranscriptionRoutes import transcription_router
from fastapi.middleware.cors import CORSMiddleware
import logging
# Configure logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.on_event("startup")
async def startup_event():
await models.create_all()
if not database.is_connected:
await database.connect()
print("connected!")
@app.on_event("shutdown")
async def shutdown_event():
if not database.is_connected:
await database.disconnect()
print("shutting down!")
@app.get("/")
async def landing_page():
return {"code": 200, "message": "still running"}
app.include_router(user_router)
app.include_router(transcription_router)