Skip to content

Instantly share code, notes, and snippets.

@TheHackerDev
Created June 12, 2017 13:43
Show Gist options
  • Save TheHackerDev/853b17e9f03c6d5a1cebd9556327e94c to your computer and use it in GitHub Desktop.
Save TheHackerDev/853b17e9f03c6d5a1cebd9556327e94c to your computer and use it in GitHub Desktop.
Simple 301 redirect server in Python
import SimpleHTTPServer
import SocketServer
# Redirect to Google.com
class Redirect(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
print self.path
self.send_response(301)
new_path = '%s%s'%('https://google.com', self.path)
self.send_header('Location', new_path)
self.end_headers()
# Listen on 127.0.0.1:8000
SocketServer.TCPServer(("127.0.0.1", 8000), Redirect).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment