$ curl -T dafile dahost.localis handy. You can use it to upload small logfiles etc without any authentication, so something like tftp.
Python's own SimpleHTTPServer is a simple webserver, but it only supports GET and HEAD requests.
By simply deriving from that class you can create a small server supporting PUT.
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
# python3 -m SimpleHTTPPutServer 8080 | |
from http.server import HTTPServer, SimpleHTTPRequestHandler | |
class PutHTTPRequestHandler(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)) | |
self.send_response(200) | |
self.end_headers() | |
def run(server_class=HTTPServer, handler_class=PutHTTPRequestHandler): | |
server_address = ('', 8000) | |
httpd = server_class(server_address, handler_class) | |
httpd.serve_forever() | |
if __name__ == '__main__': | |
run() |
No comments:
Post a Comment