"""Extend Python's built in HTTP server to save files curl or wget can be used to send files with options similar to the following curl -X PUT --upload-file somefile.txt http://localhost:8000 wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt __Note__: curl automatically appends the filename onto the end of the URL so the path can be omitted. """ import os try: import http.server as server except ImportError: # Handle Python 2.x import SimpleHTTPServer as server
classHTTPRequestHandler(server.SimpleHTTPRequestHandler): """Extend SimpleHTTPRequestHandler to handle PUT requests""" defdo_PUT(self): """Save a file following a HTTP PUT request""" filename = os.path.basename(self.path)