auto_website_update.py 1014 B

1234567891011121314151617181920212223242526272829303132333435
  1. import time
  2. import webhook_listener
  3. import json
  4. class AutoWebsiteUpdate:
  5. def __init__(self):
  6. pass
  7. def run(self):
  8. webhooks = webhook_listener.Listener(handlers={"POST": self.process_post_request}, port=8090)
  9. webhooks.start()
  10. while True:
  11. print("alive...")
  12. time.sleep(300)
  13. def process_post_request(self, request, *args, **kwargs):
  14. print("Received request:\n"
  15. + "Method: {}\n".format(request.method)
  16. + "Headers: {}\n".format(request.headers)
  17. + "Args (url path): {}\n".format(args)
  18. + "Keyword Args (url parameters): {}\n".format(kwargs)
  19. + "Body: {}".format(request.body.read(int(request.header["Content-Length"]))))
  20. if(int(request.headers.get("Content-Length", 0)) > 0):
  21. print("content")
  22. else:
  23. print("no content")
  24. if __name__ == '__main__':
  25. autoWebsiteUpdate = AutoWebsiteUpdate()
  26. autoWebsiteUpdate.run()