Files
OpenPLC_v3/webserver/config.py
Lucas Cordeiro Butzke 174c0b28ae [RTOP-26] Update webserver/config.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-21 10:04:41 -03:00

29 lines
993 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from dotenv import load_dotenv
import os
from pathlib import Path
from dotenv import load_dotenv
# Always resolve .env relative to the repo root to guarantee it is found
ENV_PATH = Path(__file__).resolve().parent.parent / ".env"
load_dotenv(dotenv_path=ENV_PATH, override=False)
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
class Config:
# Mandatory settings raise immediately if not provided
for _var in ("SQLALCHEMY_DATABASE_URI", "JWT_SECRET_KEY", "PEPPER"):
if not os.getenv(_var):
raise RuntimeError(f"Environment variable '{_var}' is required but not set")
SQLALCHEMY_DATABASE_URI = os.environ["SQLALCHEMY_DATABASE_URI"]
JWT_SECRET_KEY = os.environ["JWT_SECRET_KEY"]
PEPPER = os.environ["PEPPER"]
class DevConfig(Config):
SQLALCHEMY_TRACK_MODIFICATIONS = False # keep performance parity with prod
DEBUG = True
class ProdConfig(Config):
SQLALCHEMY_TRACK_MODIFICATIONS = False
DEBUG = False
ENV = "production"