2025-06-09 12:29:47 +00:00

49 lines
1.1 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pathlib import Path
from app.api.routes import api_router
from app.core.config import settings
app = FastAPI(
title=settings.PROJECT_NAME,
description="E-commerce API for managing products, users, and orders",
version="0.1.0",
openapi_url="/openapi.json",
docs_url="/docs",
redoc_url="/redoc",
)
# Set up CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include the API router
app.include_router(api_router)
@app.get("/")
async def root():
"""
Root endpoint returning basic information about the API.
"""
return {
"title": settings.PROJECT_NAME,
"docs": f"{settings.API_V1_STR}/docs",
"health": "/health"
}
@app.get("/health", status_code=200)
async def health_check():
"""
Health check endpoint.
"""
return {"status": "ok"}
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)