Last active
January 24, 2019 22:14
-
-
Save chb0github/4ae97f5155786e91aa700554f369eae8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python -m SimpleHTTPPutServer 8080 | |
import SimpleHTTPServer | |
import BaseHTTPServer | |
import uuid | |
class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_PUT(self): | |
length = int(self.headers["Content-Length"]) | |
path = self.translate_path(self.path) | |
with open(path, "wb") as dst: | |
dst.write(self.rfile.read(length)) | |
self.send_response(200) | |
def do_POST(self): | |
length = int(self.headers["Content-Length"]) | |
path = self.translate_path(self.path) | |
with open(str(uuid.uuid4()) + ".json", "wb") as dst: | |
dst.write(self.rfile.read(length)) | |
self.send_response(201) | |
if __name__ == '__main__': | |
SimpleHTTPServer.test(HandlerClass=SputHTTPRequestHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment