12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- # -*-coding:utf8 -*-
- import requests
- import argparse
- def inference(ids, ip, port):
- url1 = f"http://{ip}:{port}/federation/1.0/inference"
- for id in ids:
- request_data_tmp = {
- "head": {
- "serviceId": "test_model_service",
- "applyId": "209090900991",
- },
- "body": {
- "featureData": {
- "phone_num": id,
- },
- "sendToRemoteFeatureData": {
- "device_type": "imei",
- "phone_num": id,
- "encrypt_type": "raw"
- }
- }
- }
- headers = {"Content-Type": "application/json"}
- response = requests.post(url1, json=request_data_tmp, headers=headers)
- print("url地址:", url1)
- print("请求信息:\n", request_data_tmp)
- print()
- print("响应信息:\n", response.text)
- print()
- if __name__ == '__main__':
- arg_parser = argparse.ArgumentParser()
- arg_parser.add_argument("--ids", type=str, nargs='+', help="Data identification", required=False,
- default=["123", "456"])
- arg_parser.add_argument("--ip", type=str, help="serving ip", required=False, default="127.0.0.1")
- arg_parser.add_argument("--port", type=str, help="serving port", required=False, default="8059")
- args = arg_parser.parse_args()
- ids = args.ids
- ip = args.ip
- port = args.port
- inference(ids=ids, ip=ip, port=port)
|