38 lines
1003 B
Python
38 lines
1003 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from config import settings
|
|
from routers import weather
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
version=settings.VERSION,
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json",
|
|
docs_url=f"{settings.API_V1_STR}/docs",
|
|
redoc_url=f"{settings.API_V1_STR}/redoc",
|
|
)
|
|
|
|
# CORS middleware configuration
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(weather.router, prefix=settings.API_V1_STR)
|
|
|
|
@app.get("/healthz", tags=["Health"])
|
|
@app.get(f"{settings.API_V1_STR}/healthz", tags=["Health"])
|
|
async def health_check():
|
|
return {
|
|
"status": "healthy",
|
|
"service": settings.PROJECT_NAME,
|
|
"version": settings.VERSION
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|