From 685fa8b640127e5639377af6c0c9a024e37b03ff Mon Sep 17 00:00:00 2001 From: test-xy Date: Thu, 22 Aug 2024 14:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/demo.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 md/demo.py diff --git a/md/demo.py b/md/demo.py new file mode 100644 index 0000000..16432af --- /dev/null +++ b/md/demo.py @@ -0,0 +1,23 @@ +import base64 +import json +import requests + +# 定义文件路径和请求 URL +file_path = 'cat.jpg' +url = 'http://192.168.8.20:9000/api/v1.0/predictions' + +# 读取并进行 Base64 编码 +with open(file_path, 'rb') as file: + encoded_data = base64.b64encode(file.read()).decode('utf-8') + +# 创建 JSON 数据 +json_data = { + "strData": encoded_data +} + +# 发送 POST 请求 +response = requests.post(url, json=json_data) + +# 输出响应 +print(response.status_code) +print(response.json())