define_api_test.py 829 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import requests
  2. import json
  3. url = 'http://172.17.0.1:8666/CalculateFeatures/'
  4. data = {
  5. "data":[
  6. {
  7. "index": 1,
  8. "value": 503
  9. },
  10. {
  11. "index": 2,
  12. "value": 519
  13. },
  14. {
  15. "index": 2,
  16. "value": 527
  17. },
  18. {
  19. "index": 3,
  20. "value": 509
  21. },
  22. {
  23. "index": 3,
  24. "value": 527
  25. },
  26. {
  27. "index": 4,
  28. "value": 558
  29. },
  30. {
  31. "index": 5,
  32. "value": 552
  33. },
  34. {
  35. "index": 6,
  36. "value": 576
  37. }
  38. ],
  39. "start_index":None,
  40. "end_index":None
  41. }
  42. json_data = json.dumps(data)
  43. headers = {
  44. 'Content-Type': 'application/json'
  45. }
  46. response = requests.post(url, headers=headers, data=json_data)
  47. if response.status_code == 200:
  48. print(response.json())
  49. else:
  50. print(f"Error: {response.text}")