您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ext_blueprints.py 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from configs import dify_config
  2. from dify_app import DifyApp
  3. def init_app(app: DifyApp):
  4. # register blueprint routers
  5. from flask_cors import CORS # type: ignore
  6. from controllers.console import bp as console_app_bp
  7. from controllers.files import bp as files_bp
  8. from controllers.inner_api import bp as inner_api_bp
  9. from controllers.mcp import bp as mcp_bp
  10. from controllers.service_api import bp as service_api_bp
  11. from controllers.web import bp as web_bp
  12. CORS(
  13. service_api_bp,
  14. allow_headers=["Content-Type", "Authorization", "X-App-Code"],
  15. methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
  16. )
  17. app.register_blueprint(service_api_bp)
  18. CORS(
  19. web_bp,
  20. resources={r"/*": {"origins": dify_config.WEB_API_CORS_ALLOW_ORIGINS}},
  21. supports_credentials=True,
  22. allow_headers=["Content-Type", "Authorization", "X-App-Code"],
  23. methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
  24. expose_headers=["X-Version", "X-Env"],
  25. )
  26. app.register_blueprint(web_bp)
  27. CORS(
  28. console_app_bp,
  29. resources={r"/*": {"origins": dify_config.CONSOLE_CORS_ALLOW_ORIGINS}},
  30. supports_credentials=True,
  31. allow_headers=["Content-Type", "Authorization"],
  32. methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
  33. expose_headers=["X-Version", "X-Env"],
  34. )
  35. app.register_blueprint(console_app_bp)
  36. CORS(
  37. files_bp,
  38. allow_headers=["Content-Type"],
  39. methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],
  40. )
  41. app.register_blueprint(files_bp)
  42. app.register_blueprint(inner_api_bp)
  43. app.register_blueprint(mcp_bp)