Add a Flask application factory that creates and configures the Flask app, registers blueprints, initializes extensions, and sets up HTTPS context. Updated config.py to set database URI, upload folder, and certificate paths. Added a minimal routes module with auth and main blueprints. Updated app.py to use the factory and run the development server with SSL. Also staged new __pycache__ files, app.db, package.json, routes.py, and var directory.
23 lines
897 B
Python
23 lines
897 B
Python
# config.py
|
|
import os
|
|
|
|
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
class Config:
|
|
SECRET_KEY = os.environ.get("SECRET_KEY", "dev-secret-key")
|
|
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.join(BASE_DIR, 'app.db')}"
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
|
UPLOAD_FOLDER = os.path.join(BASE_DIR, "uploads")
|
|
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16 MB max upload
|
|
ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "gif"}
|
|
# HTTPS certificate paths (generated by certbot)
|
|
CERT_PATH = os.environ.get("CERT_PATH", "/etc/letsencrypt/live/example.com/fullchain.pem")
|
|
KEY_PATH = os.environ.get("KEY_PATH", "/etc/letsencrypt/live/example.com/privkey.pem")
|
|
|
|
# Admin user defaults
|
|
ADMIN_DEFAULT_USERNAME = "admin"
|
|
ADMIN_DEFAULT_PASSWORD = "admin"
|
|
|
|
# PDF export
|
|
PDF_FOLDER = os.path.join(BASE_DIR, "pdfs")
|
|
os.makedirs(PDF_FOLDER, exist_ok=True)
|