From 832e223d8b3aa0d08d8664f5c78db913ec3ea1bd Mon Sep 17 00:00:00 2001 From: OMG Tech <106702318+OMG-Tech@users.noreply.github.com> Date: Thu, 9 Jun 2022 05:54:29 +0200 Subject: [PATCH] Fix to work with python3 --- SimpleHTTPPutServer | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/SimpleHTTPPutServer b/SimpleHTTPPutServer index 77adb3a..a8175f9 100644 --- a/SimpleHTTPPutServer +++ b/SimpleHTTPPutServer @@ -1,17 +1,15 @@ -# Use this command to start the server on port 80: sudo python SimpleHTTPPutServer 80 - -import SimpleHTTPServer -import BaseHTTPServer - -class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): - def do_PUT(self): - print self.headers - length = int(self.headers["Content-Length"]) - path = self.translate_path(self.path) - with open(path, "wb") as dst: - dst.write(self.rfile.read(length)) - - -if __name__ == '__main__': - SimpleHTTPServer.test(HandlerClass=SputHTTPRequestHandler) - +# Use this command to start the server on port 80: sudo python SimpleHTTPPutServer 80 + +import http.server + +class SputHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): + def do_PUT(self): + print (self.headers) + length = int(self.headers["Content-Length"]) + path = self.translate_path(self.path) + with open(path, "wb") as dst: + dst.write(self.rfile.read(length)) + + +if __name__ == '__main__': + http.server.test(HandlerClass=SputHTTPRequestHandler) \ No newline at end of file