import os import secrets from pathlib import Path from dotenv import load_dotenv from fastapi.templating import Jinja2Templates from pydantic import BaseSettings file_dir = Path(__file__).parent templates_dir = str( file_dir.parent / 'templates' ) static_dir = str( file_dir.parent / 'static' ) debug_env = str( file_dir.parent / '.env_debug' ) is_debug = bool(os.getenv('DEBUG')) if is_debug: load_dotenv(debug_env) class Settings(BaseSettings): session_key: str = secrets.token_hex(32) csrf_key: str = secrets.token_hex(32) settings = Settings() templates = Jinja2Templates( directory=templates_dir, )