| from fastapi import FastAPI |
| from fastapi.staticfiles import StaticFiles |
| from fastapi.middleware.cors import CORSMiddleware |
| import uvicorn |
| import os |
|
|
| from .core.config import settings |
| from .api.endpoints import router |
|
|
| app = FastAPI( |
| title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json" |
| ) |
|
|
| |
| app.add_middleware( |
| CORSMiddleware, |
| allow_origins=["*"], |
| allow_credentials=True, |
| allow_methods=["*"], |
| allow_headers=["*"], |
| ) |
|
|
|
|
| @app.get("/") |
| async def root(): |
| return { |
| "status": "active", |
| "message": f"{settings.PROJECT_NAME} service is running", |
| } |
|
|
|
|
| |
| app.mount("/static", StaticFiles(directory=str(settings.STATIC_DIR)), name="static") |
|
|
| |
| app.include_router(router, prefix=settings.API_V1_STR) |
|
|
| if __name__ == "__main__": |
| port = int(os.environ.get("PORT", 8000)) |
| uvicorn.run("app.main:app", host="0.0.0.0", port=port, reload=False) |
|
|