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']}")
