from flask import Flask, jsonify from watermark_generate.controller.function_test import test from watermark_generate.controller.watermark_generate_controller import generator from watermark_generate.exceptions import BusinessException def create_app(): app = Flask(__name__) app.register_blueprint(generator) app.register_blueprint(test) @app.errorhandler(BusinessException) def handle_business_exception(ex): """处理业务异常,返回JSON提示""" return jsonify({"message": ex.message, 'code': ex.code}), 500 return app