utc.lua 615 B

123456789101112131415161718192021222324252627282930313233343536
  1. shell=util.shell
  2. function get_utc()
  3. local get_cmd="initc clock.utc"
  4. return shell(get_cmd)
  5. end
  6. function run()
  7. if request and request.data then
  8. req=json.decode(request.data)
  9. if req.method == "get" then
  10. ret.data=get_utc()
  11. end
  12. if req.method == "post" then
  13. if req.utc_status then
  14. local set_cmd='initc clock.utc %s'
  15. shell(set_cmd:format(req.utc_status))
  16. ret.status="OK"
  17. end
  18. ret.data=get_utc()
  19. end
  20. else
  21. ret.api={
  22. info="Tarih/Saat UTC Bilgisi",
  23. auth=false,
  24. method={
  25. get={},
  26. post={
  27. utc_status="utc_bilgisi",
  28. }
  29. },
  30. }
  31. end
  32. response=json.encode(ret)
  33. end