80 lines
3.7 KiB
Python
80 lines
3.7 KiB
Python
"""
|
|
config.py
|
|
=========
|
|
Configuration object loaded by Flask from environment variables.
|
|
|
|
Most operational settings are editable at runtime from /admin/settings and
|
|
stored in booth_settings.json on disk. Sensitive values (SMTP password) are
|
|
encrypted with the Flask SECRET_KEY when saved.
|
|
|
|
Environment variables (defaults shown):
|
|
Required:
|
|
- APP_SECRET_KEY long random string for Flask sessions and encryption
|
|
- ADMIN_PASSWORD plain-text password for /admin login
|
|
- PUBLIC_BASE_URL public URL customers use (e.g. https://booth.example.com)
|
|
- SMTP_PASS password for the SMTP account
|
|
Optional:
|
|
- BOOTH_NAME name in customer text and emails (default Trollgorithm Theme Songs)
|
|
- HOST_PORT docker-compose host-side port mapping (default 127.0.0.1:8000)
|
|
- INTERNAL_PORT gunicorn port inside the container (default 8000)
|
|
- MAX_REVISIONS default customer revision limit (default 2)
|
|
- PRICE_PER_VERSION price shown to customers (default 10.00)
|
|
- CURRENCY currency label (default CAD)
|
|
- DATABASE SQLite database path inside the container (default /app/data/booth.db)
|
|
- UPLOAD_FOLDER directory for uploaded MP3s inside the container (default /app/uploads)
|
|
- SETTINGS_FILE runtime settings JSON filename (default booth_settings.json)
|
|
- SMTP_HOST outgoing mail server (default mailroot8.namespro.ca)
|
|
- SMTP_PORT outgoing mail server port (default 465)
|
|
- SMTP_USER SMTP login username (default ai@hallsworth.ca)
|
|
- SMTP_FROM From address for customer emails (default ai@hallsworth.ca)
|
|
"""
|
|
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
# Load variables from .env file if present (development mode).
|
|
load_dotenv()
|
|
|
|
|
|
class Config:
|
|
# Flask secret key: used to sign session cookies and encrypt stored credentials.
|
|
SECRET_KEY = os.environ.get('APP_SECRET_KEY', 'dev-secret-change-me')
|
|
|
|
# SQLite database path inside the container.
|
|
DATABASE = os.environ.get('DATABASE', '/app/data/booth.db')
|
|
|
|
# Directory where uploaded MP3 files are stored inside the container.
|
|
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER', '/app/uploads')
|
|
|
|
# Runtime settings file: stored next to the upload folder for persistence.
|
|
SETTINGS_FILE = os.environ.get('SETTINGS_FILE', 'booth_settings.json')
|
|
|
|
# Only MP3 uploads are allowed.
|
|
ALLOWED_EXTENSIONS = {'mp3'}
|
|
|
|
# Default SMTP server settings for sending customer emails.
|
|
# These can be overridden from /admin/settings and stored encrypted.
|
|
SMTP_HOST = os.environ.get('SMTP_HOST', 'mailroot8.namespro.ca')
|
|
SMTP_PORT = int(os.environ.get('SMTP_PORT', '465'))
|
|
SMTP_USER = os.environ.get('SMTP_USER', 'ai@hallsworth.ca')
|
|
SMTP_PASS = os.environ.get('SMTP_PASS', '')
|
|
SMTP_FROM = os.environ.get('SMTP_FROM', 'ai@hallsworth.ca')
|
|
|
|
# Admin login password (plain text, set via env).
|
|
ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', '')
|
|
|
|
# Public HTTPS URL used in customer emails and QR codes.
|
|
PUBLIC_BASE_URL = os.environ.get('PUBLIC_BASE_URL', 'http://127.0.0.1:5000')
|
|
|
|
# Default customer revision limit if not overridden in runtime settings.
|
|
MAX_REVISIONS = int(os.environ.get('MAX_REVISIONS', '2'))
|
|
|
|
# Booth name used in customer-facing text and email sign-offs.
|
|
BOOTH_NAME = os.environ.get('BOOTH_NAME', 'Trollgorithm Theme Songs')
|
|
|
|
# Internal port gunicorn listens on inside the container (also exposed in Dockerfile).
|
|
INTERNAL_PORT = int(os.environ.get('INTERNAL_PORT', '8000'))
|
|
|
|
# Informational price shown to the operator/customer; actual payment is collected manually (e.g. Square).
|
|
PRICE_PER_VERSION = float(os.environ.get('PRICE_PER_VERSION', '10.00'))
|
|
CURRENCY = os.environ.get('CURRENCY', 'CAD')
|