tmpl-fastapi/app/common.py

30 lines
535 B
Python

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'
)
class Settings(BaseSettings):
debug: bool = False
session_key: str = secrets.token_hex(32)
csrf_key: str = secrets.token_hex(32)
settings = Settings()
templates = Jinja2Templates(
directory=templates_dir,
)