auto_website_update.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import time
  2. import webhook_listener
  3. import json
  4. import os
  5. class AutoWebsiteUpdate:
  6. def __init__(self):
  7. pass
  8. def run(self):
  9. webhooks = webhook_listener.Listener(handlers={"POST": self.process_post_request}, port=8090)
  10. webhooks.start()
  11. while True:
  12. #print("alive...")
  13. time.sleep(300)
  14. def process_post_request(self, request, *args, **kwargs):
  15. #stringData = "Received request:\n"
  16. #+ "Method: {}\n".format(request.method)
  17. #+ "Headers: {}\n".format(request.headers)
  18. #+ "Args (url path): {}\n".format(args)
  19. #+ "Keyword Args (url parameters): {}\n".format(kwargs)
  20. #+ "Body: {}"#.format(
  21. #request.body.read(int(request.header["Content-Length"]))
  22. #if int(request.headers.get("Content-Length", 0)) > 0
  23. #else""
  24. ##)
  25. #stringData = "asdf"
  26. #writer = open(r'reveived_data.txt','w')
  27. #writer.write(stringData)
  28. #writer.close()
  29. cmd_command = './download_extract_move.sh'
  30. os.system(cmd_command)
  31. return "received"
  32. if __name__ == '__main__':
  33. autoWebsiteUpdate = AutoWebsiteUpdate()
  34. autoWebsiteUpdate.run()