Sfoglia il codice sorgente

fix all the typo and format errors

d7gr 4 anni fa
parent
commit
864b25b020
1 ha cambiato i file con 11 aggiunte e 7 eliminazioni
  1. 11 7
      auto_website_update.py

+ 11 - 7
auto_website_update.py

@@ -7,25 +7,29 @@ class AutoWebsiteUpdate:
     def __init__(self):
         pass
     
+
     def run(self):
-        webhooks = webhook_listener.Listener(handlers={"POST": process_post_request}, port=8090)
+        webhooks = webhook_listener.Listener(handlers={"POST": self.process_post_request}, port=8090)
         webhooks.start()
         
         while True:
             print("alive...")
             time.sleep(300)
 
-    def process_post_request(self, *args, **kwargs):
+
+    def process_post_request(self, request, *args, **kwargs):
         print("Received request:\n"
             + "Method: {}\n".format(request.method)
             + "Headers: {}\n".format(request.headers)
             + "Args (url path): {}\n".format(args)
             + "Keyword Args (url parameters): {}\n".format(kwargs)
-            + "Body: {}".format(
-                request.body.read(int(request.header["Content-Length"]))
-                if int(request.headers.get("Content-Length", 0)) > 0
-                else ""  
+            + "Body: {}".format(request.body.read(int(request.header["Content-Length"]))))
+
+        if(int(request.headers.get("Content-Length", 0)) > 0):
+           print("content")
+        else:
+           print("no content") 
 
-if __name__ == "__main__":
+if __name__ == '__main__':
     autoWebsiteUpdate = AutoWebsiteUpdate()
     autoWebsiteUpdate.run()