28 lines
763 B
Python
28 lines
763 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
import uvicorn
|
|
|
|
# Import routers
|
|
from app.api.endpoints import todo_router, health_router
|
|
|
|
app = FastAPI(
|
|
title="Simple Todo API",
|
|
description="A dead simple Todo API built with FastAPI and SQLite",
|
|
version="0.1.0",
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # For a production app, replace with specific origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(todo_router, prefix="/api/v1", tags=["todos"])
|
|
app.include_router(health_router, tags=["health"])
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |