from flask import Flask, request, jsonify app = Flask(__name__) # 简单的示例函数 @app.route("/") def index(): return "Hello from Flask on Hugging Face!" # 接受 POST 请求并返回 JSON 响应的示例 @app.route('/api', methods=['POST']) def api(): data = request.get_json() if data is None: return jsonify({'error': 'Invalid JSON'}), 400 # 在这里可以添加对数据的处理逻辑 processed_data = data return jsonify({'message': 'Success', 'data': processed_data}) if __name__ == "__main__": app.run(host="0.0.0.0", port=7860, debug=True)