nopaque/config.py

99 lines
4.0 KiB
Python
Raw Permalink Normal View History

from dotenv import load_dotenv
2024-03-07 14:49:04 +00:00
from pathlib import Path
import os
2019-07-03 08:31:23 +00:00
2024-09-25 08:45:53 +00:00
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
ENV_FILE = os.path.join(BASE_DIR, 'nopaque.env')
if os.path.isfile(ENV_FILE):
load_dotenv(ENV_FILE)
2019-09-05 08:12:40 +00:00
2020-05-27 09:03:50 +00:00
class Config:
2024-09-25 08:45:53 +00:00
''' Configuration class for the Flask application. '''
# region APIFairy
2024-09-26 12:45:05 +00:00
APIFAIRY_TITLE = 'nopaque API'
2022-09-02 11:24:14 +00:00
APIFAIRY_VERSION = '0.0.1'
APIFAIRY_APISPEC_PATH = '/api/apispec.json'
2024-09-25 08:45:53 +00:00
APIFAIRY_UI = 'swagger_ui'
APIFAIRY_UI_PATH = '/api/docs'
# endregion APIFairy
2022-09-02 11:24:14 +00:00
2024-09-25 08:45:53 +00:00
# region Flask
DEBUG = os.environ.get('FLASK_DEBUG', 'false').lower() == 'true'
PREFERRED_URL_SCHEME = os.environ.get('PREFERRED_URL_SCHEME', 'http')
SECRET_KEY = os.environ.get('SECRET_KEY', 'hard to guess string')
2022-05-05 13:07:36 +00:00
SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000')
2024-09-25 08:45:53 +00:00
SESSION_COOKIE_SECURE = os.environ.get('SESSION_COOKIE_SECURE', 'false').lower() == 'true'
# endregion Flask
2022-05-05 13:07:36 +00:00
2024-09-25 08:45:53 +00:00
# region Flask-Assets
2022-05-05 13:07:36 +00:00
ASSETS_DEBUG = os.environ.get('ASSETS_DEBUG', 'false').lower() == 'true'
2024-09-25 08:45:53 +00:00
# endregion Flask-Assets
2024-09-25 08:45:53 +00:00
# region Flask-Hashids
2023-09-25 08:11:11 +00:00
HASHIDS_MIN_LENGTH = int(os.environ.get('HASHIDS_MIN_LENGTH', '16'))
2024-08-01 14:29:06 +00:00
HASHIDS_SALT = os.environ.get('HASHIDS_SALT', 'hard to guess string')
2024-09-25 08:45:53 +00:00
# endregion Flask-Hashids
2021-12-08 10:25:33 +00:00
2024-09-25 08:45:53 +00:00
# region Flask-Login
REMEMBER_COOKIE_SECURE = os.environ.get('REMEMBER_COOKIE_SECURE', 'false').lower() == 'true'
# endregion Flask-Login
2024-09-25 08:45:53 +00:00
# region Flask-Mail
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_SERVER = os.environ.get('MAIL_SERVER')
2022-05-05 13:07:36 +00:00
MAIL_PORT = int(os.environ.get('MAIL_PORT'))
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USE_SSL = os.environ.get('MAIL_USE_SSL', 'false').lower() == 'true'
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'false').lower() == 'true'
2024-09-25 08:45:53 +00:00
# endregion Flask-Mail
2024-09-25 08:45:53 +00:00
# region Flask-SQLAlchemy
2024-09-26 12:45:05 +00:00
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI', f'sqlite:///{BASE_DIR}/data.sqlite')
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
2024-09-25 08:45:53 +00:00
# endregion Flask-SQLAlchemy
2024-09-25 08:45:53 +00:00
# region nopaque
NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN')
2024-03-07 14:49:04 +00:00
NOPAQUE_DATA_DIR = Path(os.environ.get('NOPAQUE_DATA_PATH', '/mnt/nopaque'))
2024-09-25 08:45:53 +00:00
NOPAQUE_IS_PRIMARY_INSTANCE = os.environ.get('NOPAQUE_IS_PRIMARY_INSTANCE', 'true').lower() == 'true'
2022-05-05 13:07:36 +00:00
NOPAQUE_SERVICE_DESK = 'gitlab-ub-incoming+sfb1288inf-nopaque-1324-issue-@jura.uni-bielefeld.de' # noqa
2024-09-25 08:45:53 +00:00
NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI = os.environ.get('NOPAQUE_SOCKETIO_MESSAGE_QUEUE_URI')
2022-09-02 11:24:14 +00:00
2021-11-15 13:34:07 +00:00
NOPAQUE_DOCKER_REGISTRY = 'gitlab.ub.uni-bielefeld.de:4567'
NOPAQUE_DOCKER_IMAGE_PREFIX = f'{NOPAQUE_DOCKER_REGISTRY}/sfb1288inf/'
2024-09-25 08:45:53 +00:00
NOPAQUE_DOCKER_NETWORK_NAME = os.environ.get('DOCKER_NETWORK_NAME', 'nopaque')
NOPAQUE_DOCKER_REGISTRY_USERNAME = os.environ.get('NOPAQUE_DOCKER_REGISTRY_USERNAME')
NOPAQUE_DOCKER_REGISTRY_PASSWORD = os.environ.get('NOPAQUE_DOCKER_REGISTRY_PASSWORD')
2024-09-26 12:45:05 +00:00
NOPAQUE_LOG_DATE_FORMAT = os.environ.get('NOPAQUE_LOG_DATE_FORMAT', '%Y-%m-%d %H:%M:%S')
NOPAQUE_LOG_FORMAT = os.environ.get('NOPAQUE_LOG_FORMAT','[%(asctime)s] %(levelname)s: %(message)s')
2024-09-25 08:45:53 +00:00
NOPAQUE_LOG_LEVEL = os.environ.get('NOPAQUE_LOG_LEVEL', 'WARNING')
NOPAQUE_PROXY_FIX_ENABLED = os.environ.get('NOPAQUE_PROXY_FIX_ENABLED', 'false').lower() == 'true'
NOPAQUE_PROXY_FIX_X_FOR = int(os.environ.get('NOPAQUE_PROXY_FIX_X_FOR', '0'))
NOPAQUE_PROXY_FIX_X_HOST = int(os.environ.get('NOPAQUE_PROXY_FIX_X_HOST', '0'))
NOPAQUE_PROXY_FIX_X_PORT = int(os.environ.get('NOPAQUE_PROXY_FIX_X_PORT', '0'))
NOPAQUE_PROXY_FIX_X_PREFIX = int(os.environ.get('NOPAQUE_PROXY_FIX_X_PREFIX', '0'))
NOPAQUE_PROXY_FIX_X_PROTO = int(os.environ.get('NOPAQUE_PROXY_FIX_X_PROTO', '0'))
NOPAQUE_TRANSKRIBUS_ENABLED = os.environ.get('NOPAQUE_TRANSKRIBUS_ENABLED', 'false').lower() == 'true'
NOPAQUE_READCOOP_USERNAME = os.environ.get('NOPAQUE_READCOOP_USERNAME')
NOPAQUE_READCOOP_PASSWORD = os.environ.get('NOPAQUE_READCOOP_PASSWORD')
2024-12-05 14:34:11 +00:00
NOPAQUE_VERSION='1.1.0'
2024-09-25 08:45:53 +00:00
# endregion nopaque