Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Created February 12, 2017 20:32
Show Gist options
  • Save kwilczynski/03edf1d97408fb0758b821f5223bd027 to your computer and use it in GitHub Desktop.
Save kwilczynski/03edf1d97408fb0758b821f5223bd027 to your computer and use it in GitHub Desktop.
Create a simple HTTP redirect with Python on localhost.
import SimpleHTTPServer
import SocketServer
class FakeRedirect(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print self.path
self.send_response(301)
new_path = '%s%s'%('http://localhost:8081', self.path)
self.send_header('Location', new_path)
self.end_headers()
SocketServer.TCPServer(("", 8080), FakeRedirect).serve_forever()
@Quifisto
Copy link

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

@akramjaiem2
Copy link

dope ! thanks !!!

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