Created
October 23, 2016 17:34
-
-
Save planetsizebrain/6e0b4a772ce1873fbe2d8326fc9514cb to your computer and use it in GitHub Desktop.
A small extension of the default Python SimpleHTTPServer that ignores the first part of the URL
This file contains hidden or 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
import BaseHTTPServer | |
import SimpleHTTPServer | |
class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def translate_path(self, path): | |
index = path.find('/', 2) | |
return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path[index:]) | |
httpd = BaseHTTPServer.HTTPServer(server_address, MyRequestHandler) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment