getJson.cgi 857 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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_freq": 50.0,
  20. "out_freq": 50.0,
  21. "pwr": 40.0,
  22. "line_fail": 1,
  23. "low_battery": 1,
  24. "bat_cap": 92.0,
  25. "inner_temp": 27.0,
  26. "bat_time_left": 230.0,
  27. "di1": "1",
  28. "ro1": "0",
  29. "ro2": "1",
  30. "ro3": "1",
  31. "batsym": "Норма",
  32. "mode": "Профилактика сульфатации",
  33. "u_alarm": "5",
  34. "m_alarm": "0",
  35. "utc": "3.0",
  36. "netsettings_changed": "false"
  37. }
  38. print(json.dumps(JSON))