getJson.cgi 781 B

1234567891011121314151617181920212223242526272829303132333435
  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. "batsym": "Норма",
  28. "mode": "Профилактика сульфатации",
  29. "alarm": "5",
  30. "utc": "3.0",
  31. "netsettings_changed": "false"
  32. }
  33. print(json.dumps(JSON))