from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.api.api import api_router from app.core.config import settings app = FastAPI( title="E-commerce API", description="FastAPI E-commerce API with SQLite", version="0.1.0", openapi_url=f"{settings.API_V1_STR}/openapi.json", ) # Configure CORS app.add_middleware( CORSMiddleware, allow_origins=settings.BACKEND_CORS_ORIGINS, allow_credentials=True, allow_methods=["*"], # Allows all methods allow_headers=["*"], # Allows all headers ) @app.get("/") async def root(): return {"message": "Welcome to the E-commerce API"} # Include API router app.include_router(api_router, prefix=settings.API_V1_STR) if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)