Spaces:
Sleeping
Sleeping
File size: 1,293 Bytes
c7e434a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
"""
FastAPI Application
"""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.config import settings
from app.api.routes import router
from app.core.storage import ensure_upload_dir
# Create FastAPI app
app = FastAPI(
title=settings.APP_NAME,
version=settings.VERSION,
description="Audio Analysis API for Public Speaking Assessment"
)
# CORS
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(router, prefix="/api/v1", tags=["audio-analysis"])
# Startup event
@app.on_event("startup")
async def startup_event():
"""Initialize on startup"""
print(f"๐ Starting {settings.APP_NAME} v{settings.VERSION}")
ensure_upload_dir()
print(f"โ
Upload directory ready: {settings.UPLOAD_DIR}")
# Root endpoint
@app.get("/")
async def root():
"""Root endpoint"""
return {
"app": settings.APP_NAME,
"version": settings.VERSION,
"docs": "/docs",
"health": "/api/v1/health"
}
if __name__ == "__main__":
import uvicorn
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=8000,
reload=settings.DEBUG
)
|