diff --git a/api/app_factory.py b/api/app_factory.py index 47a67492770e3d..fd5b654bcbe4d9 100644 --- a/api/app_factory.py +++ b/api/app_factory.py @@ -25,7 +25,7 @@ ext_sentry, ext_storage, ext_timezone, - ext_warnings, + ext_warnings, ext_set_secretkey, ) @@ -52,21 +52,19 @@ def create_flask_app_with_configs() -> Flask: return dify_app -def create_app() -> Flask: +def create_app() -> DifyApp: app = create_flask_app_with_configs() - app.secret_key = dify_config.SECRET_KEY initialize_extensions(app) return app -def initialize_extensions(app: Flask): - # Since the application instance is now created, pass it to each Flask - # extension instance to bind it to the Flask application instance (app) +def initialize_extensions(app: DifyApp): extensions = [ ext_timezone, ext_logging, ext_warnings, ext_import_modules, + ext_set_secretkey, ext_compress, ext_code_based_extension, ext_database, diff --git a/api/extensions/ext_set_secretkey.py b/api/extensions/ext_set_secretkey.py new file mode 100644 index 00000000000000..6b246113da9d96 --- /dev/null +++ b/api/extensions/ext_set_secretkey.py @@ -0,0 +1,6 @@ +from configs import dify_config +from dify_app import DifyApp + + +def init_app(app: DifyApp): + app.secret_key = dify_config.SECRET_KEY \ No newline at end of file