|
@@ -30,7 +30,20 @@ def get_data():
|
|
|
})
|
|
|
|
|
|
# POST 上传单张图片
|
|
|
+@app.route('/api/upload_single_image', methods=['POST'])
|
|
|
+def upload_image():
|
|
|
+ # 获取上传的文件
|
|
|
+ img = request.files['img1']
|
|
|
+ # 保存文件
|
|
|
+ filePath = 'predict/' + str(uuid.uuid4()) + img.filename
|
|
|
|
|
|
+ img.save(filePath)
|
|
|
+ return jsonify({
|
|
|
+ "message": "上传成功",
|
|
|
+ "data":{
|
|
|
+ "img": filePath
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
@app.route('/api/upload_single_image', methods=['POST'])
|
|
|
def upload_single_image():
|
|
@@ -108,27 +121,27 @@ def save_image():
|
|
|
|
|
|
return jsonify({
|
|
|
"message": "保存成功",
|
|
|
- "data": {
|
|
|
+ "data":{
|
|
|
# "img1": img1Path,
|
|
|
# "img2": img2Path,
|
|
|
- "img1": 100
|
|
|
+ "img": 100,
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-# # POST 分析图片
|
|
|
-# @app.route('/api/detect_image', methods=['POST'])
|
|
|
-# def detect_image():
|
|
|
-# # 获取图片路径
|
|
|
-# data = request.get_json()
|
|
|
-# img1 = data['img1']
|
|
|
-# img2 = data['img2']
|
|
|
-# getImgPath=start(img1,img2,outputPath)
|
|
|
-# return jsonify({
|
|
|
-# "message": "分析成功",
|
|
|
-# "data":{
|
|
|
-# "img": host+":4100/"+getImgPath
|
|
|
-# }
|
|
|
-# })
|
|
|
+# POST 分析图片
|
|
|
+@app.route('/api/detect_image', methods=['POST'])
|
|
|
+def detect_image():
|
|
|
+ # 获取图片路径
|
|
|
+ data = request.get_json()
|
|
|
+ img1 = data['img1']
|
|
|
+ img2 = data['img2']
|
|
|
+ getImgPath=start(img1,img2)
|
|
|
+ return jsonify({
|
|
|
+ "message": "分析成功",
|
|
|
+ "data":{
|
|
|
+ "img": host+'/predict/'+getImgPath
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
# 访问静态文件
|
|
|
|