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())