todoapp-7thmky/main.py

41 lines
924 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(
title="Todo App API",
description="A simple todo application API",
version="1.0.0",
openapi_url="/openapi.json"
)
# Configure CORS to allow all origins
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
"""Base URL endpoint returning project information"""
return {
"title": "Todo App API",
"documentation": "/docs",
"redoc": "/redoc",
"health": "/health",
"openapi": "/openapi.json"
}
@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy", "message": "Todo App API is running"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)