getJson.cgi 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!C:\Python36\python.exe
  2. # -*- coding: utf-8 -*-
  3. import json
  4. import random
  5. print("Content-Type: text/html")
  6. print("")
  7. A0 = str(random.choice([0,1]))
  8. A1 = str(random.choice([0,1]))
  9. A2 = str(random.choice([0,1]))
  10. A3 = str(random.choice([0,1]))
  11. A4 = str(random.choice([0,1]))
  12. A5 = str(0)
  13. A6 = str(random.choice([0,1]))
  14. A7 = str(random.choice([0,1]))
  15. bitmask = A0 + A1 + A2 + A3 + A4 + A5 + A6 + A7
  16. JSON = {
  17. "AC": 218.8,
  18. "DC": 230.4,
  19. "in_cur": 48.0,
  20. "out_cur": 42.5,
  21. "in_freq": 50.0,
  22. "out_freq": 50.0,
  23. "pwr": 40.0,
  24. "line_fail": 1,
  25. "low_battery": 1,
  26. "bat_volt": 210,
  27. "bat_cap": 1200,
  28. "bat_rem_cap": 92.0,
  29. "bat_exp": "12.12.2021",
  30. "inner_temp": 27.0,
  31. "bat_time_left": 230.0,
  32. "di1": "1",
  33. "ro1": "0",
  34. "ro2": "1",
  35. "ro3": "1",
  36. "batsym": "Норма",
  37. "mode": "Профилактика сульфатации",
  38. "u_alarm": "5",
  39. "m_alarm": "0",
  40. "utc": "3.0",
  41. "netsettings_changed": "false"
  42. }
  43. print(json.dumps(JSON))