|
@@ -1,4 +1,4 @@
|
|
|
-from flask import Flask, request, jsonify
|
|
|
+from flask import Flask, request, jsonify,send_from_directory
|
|
|
import uuid
|
|
|
from change_detect import start
|
|
|
import requests
|
|
@@ -8,6 +8,10 @@ from io import BytesIO
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
+# 设置静态文件夹(如果您想指定路径)
|
|
|
+app.config['UPLOAD_FOLDER'] = 'predict'
|
|
|
+host = 'http://192.168.60.2'
|
|
|
+
|
|
|
# GET 请求接口示例
|
|
|
@app.route('/api/get_data', methods=['GET'])
|
|
|
def get_data():
|
|
@@ -91,9 +95,14 @@ def detect_image():
|
|
|
return jsonify({
|
|
|
"message": "分析成功",
|
|
|
"data":{
|
|
|
- "img": getImgPath
|
|
|
+ "img": host+'/predict/'+getImgPath
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+# 访问静态文件
|
|
|
+@app.route('/predict/<filename>')
|
|
|
+def view_file(filename):
|
|
|
+ return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
app.run(debug=True,host='0.0.0.0',port=4100)
|