__init__.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from flask import Blueprint
  2. # 创建蓝图
  3. user_routes = Blueprint('user', __name__, url_prefix='/user')
  4. model_routes = Blueprint('model', __name__, url_prefix='/model')
  5. media_routes = Blueprint('media', __name__, url_prefix='/media')
  6. detection_routes = Blueprint('detection', __name__, url_prefix='/detection')
  7. operation_routes = Blueprint('operation', __name__, url_prefix='/operation')
  8. file_routes = Blueprint('file', __name__, url_prefix='/file')
  9. def register_routes(app):
  10. """
  11. 将所有的蓝图注册到 Flask 应用中。
  12. 该函数用于将定义的蓝图(例如 user_routes)与 Flask 应用绑定,
  13. 使得在应用中能够通过指定的 URL 前缀访问相关视图函数。
  14. :param app: Flask 应用实例
  15. :type app: Flask
  16. :return: None
  17. """
  18. # 注册蓝图
  19. app.register_blueprint(user_routes)
  20. app.register_blueprint(model_routes)
  21. app.register_blueprint(media_routes)
  22. app.register_blueprint(detection_routes)
  23. app.register_blueprint(operation_routes)
  24. app.register_blueprint(file_routes)
  25. from .user_route import *
  26. from .model_route import *
  27. from .media_route import *
  28. from .detection_route import *
  29. from .operation_route import *
  30. from .file_route import *