Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create a simple HTTP redirect with Python on localhost.
import SimpleHTTPServer
import SocketServer
class FakeRedirect(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print self.path
new_path = '%s%s'%('http://localhost:8081', self.path)
self.send_header('Location', new_path)
SocketServer.TCPServer(("", 8080), FakeRedirect).serve_forever()

This comment has been minimized.

Copy link

@Quifisto Quifisto commented May 28, 2019

This came in really handy for me.
Thanks for putting this example online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment