api_test.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import requests
  2. import json
  3. url = 'http://172.17.0.1:8888/analysis/time'
  4. data={
  5. "ids":[67803,67804],
  6. "windCode":"SKF001",
  7. "analysisType":"time",
  8. "fmin":None,
  9. "fmax":None,
  10. }
  11. json_data = json.dumps(data)
  12. print(json_data)
  13. headers = {
  14. 'Content-Type': 'application/json'
  15. }
  16. response = requests.post(url, headers=headers, data=json_data)
  17. # print("response:",response.json())
  18. if response.status_code == 200:
  19. # print(response.json())
  20. # print("response.text",response.text) # 打印原始响应内容
  21. try:
  22. data = response.json()
  23. print(data)
  24. except json.JSONDecodeError as e:
  25. print(f"解析JSON时出错: {e}")
  26. else:
  27. print(f"Error: {response.text}")
  28. '''
  29. {"ids": [67803, 67804],
  30. "windCode": "SKF001_wave",
  31. "analysisType": "trend",
  32. "fmin": null,
  33. "fmax": null}
  34. {"type": "trend",
  35. "data": [{"fs": 2560.0,
  36. "Mean": -0.0,
  37. "Max": 4.84,
  38. "Min": -6.0,
  39. "Xrms": 1.59,
  40. "Xp": 5.42,
  41. "If": 4.26,
  42. "Cf": 3.42,
  43. "Sf": -128989487.68,
  44. "Ce": 5.02,
  45. "Cw": 1.58,
  46. "Cq": 2.91,
  47. "velocity_rms": 0.03491697493565808,
  48. "time_stamp": "2024-07-01 00:00:14"},
  49. {"fs": 2560.0,
  50. "Mean": 0.0,
  51. "Max": 0.13,
  52. "Min": -0.17,
  53. "Xrms": 0.06,
  54. "Xp": 0.15,
  55. "If": 3.13,
  56. "Cf": 2.56,
  57. "Sf": 115003052.92,
  58. "Ce": 3.63,
  59. "Cw": 1.51,
  60. "Cq": 2.6,
  61. "velocity_rms": 0.05647856377107759,
  62. "time_stamp": "2024-07-01 00:00:27"}]}
  63. '''