Created
June 12, 2017 13:43
-
-
Save TheHackerDev/853b17e9f03c6d5a1cebd9556327e94c to your computer and use it in GitHub Desktop.
Simple 301 redirect server in Python
This file contains 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 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