diff --git a/private_dot_local/bin/pyserver.py b/private_dot_local/bin/pyserver.py index efb5553..a613bae 100644 --- a/private_dot_local/bin/pyserver.py +++ b/private_dot_local/bin/pyserver.py @@ -23,10 +23,22 @@ class S(BaseHTTPRequestHandler): post_data = self.rfile.read(content_length) # <--- Gets the data itself logging.info("POST request,\nPath: %s\nHeaders:\n%s\n\nBody:\n%s\n", str(self.path), str(self.headers), post_data.decode('utf-8')) - self._set_response() self.wfile.write("POST request for {}".format(self.path).encode('utf-8')) + def do_PUT(self): + content_length = int(self.headers['Content-Length']) # <--- Gets the size of data + post_data = self.rfile.read(content_length) # <--- Gets the data itself + logging.info("PUT request,\nPath: %s\nHeaders:\n%s\n\nBody:\n%s\n", + str(self.path), str(self.headers), post_data.decode('utf-8')) + self._set_response() + self.wfile.write("PUT request for {}".format(self.path).encode('utf-8')) + + def do_DELETE(self): + logging.info("DELETE request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers)) + self._set_response() + self.wfile.write("DELETE request for {}".format(self.path).encode('utf-8')) + def run(server_class=HTTPServer, handler_class=S, port=8080): logging.basicConfig(level=logging.INFO) fh = logging.FileHandler('/tmp/pyserver.log')