40 lines
954 B
Python
40 lines
954 B
Python
"""
|
|
FastAPI Todo Application Entry Point
|
|
"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.routers import health, todos
|
|
from app.core.database import create_db_and_tables
|
|
|
|
app = FastAPI(
|
|
title="Todo API",
|
|
description="A simple Todo API built with FastAPI and SQLite",
|
|
version="0.1.0",
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # Allows all origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"], # Allows all methods
|
|
allow_headers=["*"], # Allows all headers
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(todos.router, prefix="/api", tags=["todos"])
|
|
app.include_router(health.router, tags=["health"])
|
|
|
|
|
|
@app.on_event("startup")
|
|
def on_startup():
|
|
"""Create database tables on application startup"""
|
|
create_db_and_tables()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|