2023-05-15 08:51:32 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
import dotenv
|
|
|
|
|
|
|
|
DEFAULTS = {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def get_env(key):
|
|
|
|
return os.environ.get(key, DEFAULTS.get(key))
|
|
|
|
|
|
|
|
|
|
|
|
def get_bool_env(key):
|
2024-01-17 15:02:27 +08:00
|
|
|
value = get_env(key)
|
|
|
|
return value.lower() == 'true' if value is not None else False
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
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):
|
2024-06-19 13:41:12 +08:00
|
|
|
dotenv.load_dotenv()
|
|
|
|
|
2023-05-15 08:51:32 +08:00
|
|
|
self.TESTING = False
|
2024-06-24 14:41:07 +08:00
|
|
|
self.APPLICATION_NAME = "langgenius/dify"
|
2024-04-18 17:33:32 +08:00
|
|
|
|
2023-11-13 22:05:46 +08:00
|
|
|
# cors settings
|
|
|
|
self.CONSOLE_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
|
2024-06-19 13:41:12 +08:00
|
|
|
'CONSOLE_CORS_ALLOW_ORIGINS', get_env('CONSOLE_WEB_URL'))
|
2023-11-13 22:05:46 +08:00
|
|
|
self.WEB_API_CORS_ALLOW_ORIGINS = get_cors_allow_origins(
|
|
|
|
'WEB_API_CORS_ALLOW_ORIGINS', '*')
|