
- Setup project structure with FastAPI, SQLAlchemy, and SQLite - Create Todo model and database migrations - Implement CRUD API endpoints - Add error handling and validation - Update README with documentation and examples generated with BackendIM... (backend.im)
26 lines
626 B
Python
26 lines
626 B
Python
import os
|
|
from pathlib import Path
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
# Project settings
|
|
PROJECT_NAME: str = "Todo API"
|
|
API_V1_STR: str = "/api/v1"
|
|
DEBUG: bool = True
|
|
|
|
# Server settings
|
|
HOST: str = "0.0.0.0"
|
|
PORT: int = 8000
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
|
|
# Ensure DB directory exists
|
|
Path(settings.DB_DIR).mkdir(parents=True, exist_ok=True)
|
|
|
|
settings = Settings() |