
- Set up FastAPI application with CORS support - Created SQLite database configuration with absolute paths - Implemented Todo model with SQLAlchemy - Added full CRUD operations for todos - Created API endpoints with proper error handling - Set up Alembic for database migrations - Added health check and base URL endpoints - Updated README with comprehensive documentation - Configured project structure following best practices Features: - Complete Todo CRUD API - SQLite database with proper path configuration - Database migrations with Alembic - API documentation at /docs and /redoc - Health check endpoint at /health - CORS enabled for all origins - Proper error handling and validation
14 lines
579 B
Python
14 lines
579 B
Python
from datetime import datetime
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String, Text
|
|
from app.db.base import Base
|
|
|
|
|
|
class Todo(Base):
|
|
__tablename__ = "todos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(200), nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
completed = Column(Boolean, default=False, nullable=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False) |