2025-05-16 01:35:23 +00:00

46 lines
1.0 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api import todos_router
from app.db.database import Base, engine
# Create tables in database
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Simple Todo Application",
description="A simple todo application API built with FastAPI",
version="0.1.0",
)
# Setup CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(todos_router)
# Health endpoint
@app.get("/health", tags=["Health"])
def health_check():
"""
Health check endpoint to verify the API is running
"""
return {"status": "healthy"}
@app.get("/", tags=["Root"])
def read_root():
"""
Root endpoint with links to API documentation
"""
return {
"message": "Welcome to the Simple Todo Application API",
"documentation": "/docs",
"alternative_doc": "/redoc",
}