Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,23 @@
|
|
1 |
-
from flask import Flask
|
2 |
|
3 |
app = Flask(__name__)
|
4 |
|
|
|
5 |
@app.route("/")
|
6 |
-
def
|
7 |
-
return "Hello from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
if __name__ == "__main__":
|
10 |
-
app.run(debug=True)
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
|
3 |
app = Flask(__name__)
|
4 |
|
5 |
+
# 简单的示例函数
|
6 |
@app.route("/")
|
7 |
+
def index():
|
8 |
+
return "Hello from Flask on Hugging Face!"
|
9 |
+
|
10 |
+
# 接受 POST 请求并返回 JSON 响应的示例
|
11 |
+
@app.route('/api', methods=['POST'])
|
12 |
+
def api():
|
13 |
+
data = request.get_json()
|
14 |
+
if data is None:
|
15 |
+
return jsonify({'error': 'Invalid JSON'}), 400
|
16 |
+
|
17 |
+
# 在这里可以添加对数据的处理逻辑
|
18 |
+
processed_data = data
|
19 |
+
|
20 |
+
return jsonify({'message': 'Success', 'data': processed_data})
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
+
app.run(host="0.0.0.0", port=7860, debug=True)
|