Automated Action 29d75cdf08 Implement Task Management API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models and schemas for tasks
- Implement CRUD operations for tasks
- Add API endpoints for task management
- Create Alembic migrations for the database
- Add health check endpoint
- Implement error handling
- Add documentation in README.md
2025-05-17 11:20:00 +00:00

34 lines
910 B
Python

from pathlib import Path
from typing import List, Union
from pydantic import AnyHttpUrl, validator
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
PROJECT_NAME: str = "Task Management API"
# CORS Configuration
BACKEND_CORS_ORIGINS: List[Union[str, AnyHttpUrl]] = []
@validator("BACKEND_CORS_ORIGINS", pre=True)
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
if isinstance(v, str) and not v.startswith("["):
return [i.strip() for i in v.split(",")]
elif isinstance(v, (list, str)):
return v
raise ValueError(v)
# Database Configuration
DB_DIR: Path = Path("/app") / "storage" / "db"
class Config:
case_sensitive = True
settings = Settings()
# Create database directory
settings.DB_DIR.mkdir(parents=True, exist_ok=True)