44 lines
831 B
Python
44 lines
831 B
Python
|
|
from fastapi import FastAPI
|
||
|
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
|
|
||
|
|
from src.core.config import settings
|
||
|
|
|
||
|
|
app = FastAPI(
|
||
|
|
title=settings.app_name,
|
||
|
|
version=settings.app_version,
|
||
|
|
debug=settings.debug
|
||
|
|
)
|
||
|
|
|
||
|
|
# CORS middleware
|
||
|
|
app.add_middleware(
|
||
|
|
CORSMiddleware,
|
||
|
|
allow_origins=["*"] if settings.debug else [],
|
||
|
|
allow_credentials=True,
|
||
|
|
allow_methods=["*"],
|
||
|
|
allow_headers=["*"],
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@app.get("/")
|
||
|
|
async def root():
|
||
|
|
return {
|
||
|
|
"app": settings.app_name,
|
||
|
|
"version": settings.app_version,
|
||
|
|
"status": "running"
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@app.get("/health")
|
||
|
|
async def health_check():
|
||
|
|
return {"status": "healthy"}
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
import uvicorn
|
||
|
|
|
||
|
|
uvicorn.run(
|
||
|
|
"src.main:app",
|
||
|
|
host=settings.host,
|
||
|
|
port=settings.port,
|
||
|
|
reload=settings.debug
|
||
|
|
)
|