
Create a simple Todo API with FastAPI and SQLite with CRUD functionality, health check, error handling, and API documentation.
22 lines
462 B
Python
22 lines
462 B
Python
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "Todo API"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
DB_NAME: str = "db.sqlite"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings()
|
|
|
|
# Ensure DB directory exists
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True) |