Automated Action 93c528a258 Create FastAPI REST API with SQLite
- Set up project structure and dependencies
- Create database models with SQLAlchemy
- Implement API endpoints for CRUD operations
- Set up Alembic for database migrations
- Add health check endpoint
- Configure Ruff for linting
- Update documentation in README
2025-05-29 10:18:27 +00:00

39 lines
994 B
Python

from pathlib import Path
from typing import Optional
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# Base settings
PROJECT_NAME: str = "QuickRestAPI"
PROJECT_DESCRIPTION: str = "A simple REST API built with FastAPI and SQLite"
PROJECT_VERSION: str = "0.1.0"
# Server settings
HOST: str = "0.0.0.0"
PORT: int = 8000
DEBUG: bool = True
# Database settings
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: Optional[str] = None
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Ensure DB directory exists
self.DB_DIR.mkdir(parents=True, exist_ok=True)
# Set database URL if not provided
if self.SQLALCHEMY_DATABASE_URL is None:
self.SQLALCHEMY_DATABASE_URL = f"sqlite:///{self.DB_DIR}/db.sqlite"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
case_sensitive = True
settings = Settings()