فهرست منبع

添加代理测试

gushoubang 9 ماه پیش
والد
کامیت
d9e1ab6704
1فایلهای تغییر یافته به همراه35 افزوده شده و 16 حذف شده
  1. 35 16
      main.py

+ 35 - 16
main.py

@@ -1,6 +1,6 @@
-from flask import Flask, request, jsonify,send_from_directory
+from flask import Flask, request, jsonify,send_from_directory,Response
 import uuid
-from change_detect import start
+# from change_detect import start
 import requests
 from PIL import Image
 from io import BytesIO
@@ -84,25 +84,44 @@ def save_image():
         }
     })
 
-# 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
-        }
-    })
+# # 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
+#         }
+#     })
 
 # 访问静态文件
 @app.route('/predict/<filename>')
 def view_file(filename):
     return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
 
+# 测试转发接口
+# 目标代理服务 URL
+WMS_PROXY_URL = "http://192.168.60.2:9206/proxy/handle/22d38ad36d354a6fb8adc2fb378a66d6/siweiserver/wms"
+@app.route('/proxy/wms', methods=['GET'])
+def proxy_wms():
+    # 从客户端请求中获取参数
+    params = request.args.to_dict()
+
+
+    # 拼接 WMS 请求 URL
+    wms_url = WMS_PROXY_URL + "?" + "&".join([f"{key}={value}" for key, value in params.items()])
+    # 发送请求到目标 WMS 服务
+    response = requests.get(wms_url, stream=True)
+
+    # 返回目标服务的响应给客户端
+    return Response(response.iter_content(chunk_size=1024), content_type=response.headers['Content-Type'])
+
+
+
 if __name__ == '__main__':
     app.run(debug=True,host='0.0.0.0',port=4100)