mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
13fcd7a901
Signed-off-by: Xiaoguang Sun <sunxiaoguang@gmail.com>
43 lines
961 B
Python
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', '*')
|