epicpost/settings.py_example
2022-08-07 20:15:02 +08:00

37 lines
1.2 KiB
Plaintext

import logging
import socket
import collections
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET = ''
DEBUG = True
COINCODE = ''
PSQL_HOST = "127.0.0.1:5432"
PSQL_DB = ''
PSQL_USER = 'postgres'
PSQL_PASS = ''
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI', 'postgresql://{user}:{pw}@localhost/{db}').format(user=PSQL_USER, pw=PSQL_PASS, db=PSQL_DB)
SESSION_COOKIE_NAME = os.environ.get('{coincode}_SESSION_COOKIE_NAME', '{coincode}_id').format(coincode=COINCODE.upper())
SESSION_PREFIX = os.environ.get('{coincode}_SESSION_PREFIX', 'session:').format(coincode=COINCODE.upper())
REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1')
REDIS_PORT = int(os.environ.get('REDIS_PORT', 6379))
REDIS_PASSWD = os.environ.get('REDIS_PASSWD', None)
REDIS_URI = "redis://"
if REDIS_PASSWD:
REDIS_URI += f":{REDIS_PASSWD}"
REDIS_URI += f"@{REDIS_HOST}:{REDIS_PORT}"
BIND_HOST = os.environ.get("BIND_HOST", "0.0.0.0")
if not BIND_HOST:
raise Exception("BIND_HOST missing")
BIND_PORT = os.environ.get("BIND_PORT", 5004)
if not BIND_PORT:
raise Exception("BIND_PORT missing")
HOSTNAME = os.environ.get("{coincode}_HOSTNAME", socket.gethostname()).format(coincode=COINCODE.upper())