dify/api/config.py
Xiaoguang Sun 13fcd7a901
feat: Add program_name attribute to TiDB connection (#5499)
Signed-off-by: Xiaoguang Sun <sunxiaoguang@gmail.com>
2024-06-24 14:41:07 +08:00

43 lines
961 B
Python

import os
import dotenv
DEFAULTS = {
}
def get_env(key):
return os.environ.get(key, DEFAULTS.get(key))
def get_bool_env(key):
value = get_env(key)
return value.lower() == 'true' if value is not None else False
def get_cors_allow_origins(env, default):
cors_allow_origins = []
if get_env(env):
for origin in get_env(env).split(','):
cors_allow_origins.append(origin)
else:
cors_allow_origins = [default]
return cors_allow_origins
class Config:
"""Application configuration class."""
def __init__(self):
dotenv.load_dotenv()
self.TESTING = False
self.APPLICATION_NAME = "langgenius/dify"
# cors settings
self.CONSOLE_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
'CONSOLE_CORS_ALLOW_ORIGINS', get_env('CONSOLE_WEB_URL'))
self.WEB_API_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
'WEB_API_CORS_ALLOW_ORIGINS', '*')