Skip to content

Instantly share code, notes, and snippets.

Created Nov 21, 2019
What would you like to do?
Prank Redirect
import SimpleHTTPServer
import SocketServer
import random
from urlparse import urlparse, parse_qs
class Redirect(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
term = parse_qs(urlparse(self.path).query)['q'][0]
if random.randint(1, 101) > 95:
self.send_header('Location', '')
# self.send_header('Location', '' % (term))
self.send_header('Location', '' % (term))
SocketServer.TCPServer(("", 8080), Redirect).serve_forever()
# nohup python &
# http://localhost:8080/q?q=%s

This comment has been minimized.

Copy link

@dominicwong617 dominicwong617 commented Nov 21, 2019

I think it should be lower than 95, more like 50

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