|  | @@ -30,17 +30,23 @@ def get_data():
 | 
											
												
													
														|  |      })
 |  |      })
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  # POST 上传单张图片
 |  |  # POST 上传单张图片
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  @app.route('/api/upload_single_image', methods=['POST'])
 |  |  @app.route('/api/upload_single_image', methods=['POST'])
 | 
											
												
													
														|  | -def upload_image():
 |  | 
 | 
											
												
													
														|  | 
 |  | +def upload_single_image():
 | 
											
												
													
														|  |      # 获取上传的文件
 |  |      # 获取上传的文件
 | 
											
												
													
														|  | -    img = request.files['img1']
 |  | 
 | 
											
												
													
														|  | 
 |  | +    img = request.files['img']
 | 
											
												
													
														|  | 
 |  | +    # 文件夹不存在则创建
 | 
											
												
													
														|  | 
 |  | +    if not os.path.exists(uploadPath):
 | 
											
												
													
														|  | 
 |  | +        os.makedirs(uploadPath)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      # 保存文件
 |  |      # 保存文件
 | 
											
												
													
														|  | -    filePath = 'predict/' + str(uuid.uuid4()) + img.filename
 |  | 
 | 
											
												
													
														|  | 
 |  | +    filePath = uploadPath + str(uuid.uuid4()) + img.filename
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      img.save(filePath)
 |  |      img.save(filePath)
 | 
											
												
													
														|  |      return jsonify({
 |  |      return jsonify({
 | 
											
												
													
														|  |          "message": "上传成功",
 |  |          "message": "上传成功",
 | 
											
												
													
														|  | -        "data":{
 |  | 
 | 
											
												
													
														|  | 
 |  | +        "data": {
 | 
											
												
													
														|  |              "img": filePath
 |  |              "img": filePath
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      })
 |  |      })
 | 
											
										
											
												
													
														|  | @@ -121,7 +127,7 @@ def save_image():
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      return jsonify({
 |  |      return jsonify({
 | 
											
												
													
														|  |          "message": "保存成功",
 |  |          "message": "保存成功",
 | 
											
												
													
														|  | -        "data":{
 |  | 
 | 
											
												
													
														|  | 
 |  | +        "data": {
 | 
											
												
													
														|  |              # "img1": img1Path,
 |  |              # "img1": img1Path,
 | 
											
												
													
														|  |              # "img2": img2Path,
 |  |              # "img2": img2Path,
 | 
											
												
													
														|  |              "img": 100,
 |  |              "img": 100,
 | 
											
										
											
												
													
														|  | @@ -135,10 +141,10 @@ def detect_image():
 | 
											
												
													
														|  |      data = request.get_json()
 |  |      data = request.get_json()
 | 
											
												
													
														|  |      img1 = data['img1']
 |  |      img1 = data['img1']
 | 
											
												
													
														|  |      img2 = data['img2']
 |  |      img2 = data['img2']
 | 
											
												
													
														|  | -    getImgPath=start(img1,img2)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    getImgPath = start(img1, img2)
 | 
											
												
													
														|  |      return jsonify({
 |  |      return jsonify({
 | 
											
												
													
														|  |          "message": "分析成功",
 |  |          "message": "分析成功",
 | 
											
												
													
														|  | -        "data":{
 |  | 
 | 
											
												
													
														|  | 
 |  | +        "data": {
 | 
											
												
													
														|  |              "img": host+'/predict/'+getImgPath
 |  |              "img": host+'/predict/'+getImgPath
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      })
 |  |      })
 | 
											
										
											
												
													
														|  | @@ -174,6 +180,5 @@ def view_file(filename):
 | 
											
												
													
														|  |  #     # 返回目标服务的响应给客户端
 |  |  #     # 返回目标服务的响应给客户端
 | 
											
												
													
														|  |  #     return Response(response.iter_content(chunk_size=1024), content_type=response.headers['Content-Type'])
 |  |  #     return Response(response.iter_content(chunk_size=1024), content_type=response.headers['Content-Type'])
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  if __name__ == '__main__':
 |  |  if __name__ == '__main__':
 | 
											
												
													
														|  |      app.run(debug=True, host='0.0.0.0', port=4100)
 |  |      app.run(debug=True, host='0.0.0.0', port=4100)
 |