tmpl-fastapi/app/common.py

24 lines
468 B
Python

import secrets
from pathlib import Path
from fastapi.templating import Jinja2Templates
from pydantic import BaseSettings
file_dir = Path(__file__).parent
class Settings(BaseSettings):
secret_key: str = secrets.token_hex(32)
templates_dir: str = str(
file_dir.parent / 'templates'
)
static_dir: str = str(
file_dir.parent / 'static'
)
settings = Settings()
templates = Jinja2Templates(
directory=settings.templates_dir,
)