pictures_get_data.py
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import requests
import requests
import json
def get_data():
# url = 'http://192.168.200.210:5000/search'
url = 'http://113.100.143.162:8888/search' # 添加路由路径
data = {
'site_name': 'us',
'search_key': 'asin',
'search_value': 'B07HFVW34D',
'top_k': 100
}
files = {'file': open(rf'F:\milvus\data/B078S1569F.jpg', 'rb')}
response = requests.post(url, data=data, files=files)
print(response.json())
def upload_img():
url = 'http://192.168.200.210:5000/upload'
files = {'file': open(rf'F:\milvus\data/B078GMWG2S.jpg', 'rb')}
response = requests.post(url, files=files)
print(response)
if __name__ == '__main__':
get_data()
# upload_img()
# if __name__ == '__main__':
# site_name = 'us' # 参数1:站点
# search_key = 'asin' # 参数2:查询类型
# search_value = 'B09KD8YJZB' # 参数3:查询值
# top_k = 100 # 参数4:最相似的top前k个值
#
# url = 'http://192.168.200.210:5000/search' # 添加路由路径
# params = {
# 'site_name': site_name,
# 'search_key': search_key,
# 'search_value': search_value,
# 'top_k': top_k
# }
# resp = requests.get(url, timeout=90, params=params) # 修改 data 为 params
# resp_json = resp.json() # 将响应解析为 JSON
# print(resp_json)
# print(type(resp_json))
# # print(f"indices: {resp_json['indices']}") # 访问 'indices' 和 'distances'
# # print(f"distances: {resp_json['distances']}")
# # print(f"asin_list: {resp_json['asin_list']}")
# print(f"similarities_dict: {resp_json['similarities_dict']}")