上传文件至 md
This commit is contained in:
parent
69b5eb9b4b
commit
685fa8b640
|
@ -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())
|
Loading…
Reference in New Issue