36 lines
933 B
Python
36 lines
933 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
import os
|
|
from app.api.v1.api import api_router
|
|
from app.core.config import settings
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[str(origin).strip("/") for origin in [settings.FRONTEND_URL, "*"]],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
|
# Mount uploads directory to serve files
|
|
if not os.path.exists("uploads"):
|
|
os.makedirs("uploads")
|
|
app.mount("/api/v1/uploads", StaticFiles(directory="uploads"), name="uploads")
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"message": f"{settings.PROJECT_NAME} is running"}
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "ok"}
|