34 行
761 B
Python
34 行
761 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.router import api_router
|
|
from app.core.config import settings
|
|
|
|
app = FastAPI(
|
|
title="FastAPI Project",
|
|
description="A clean FastAPI project structure",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API router
|
|
app.include_router(api_router, prefix="/api/v1")
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Welcome to FastAPI"}
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8000) |