-
-
Save emadshanab/39b006cf751a074a947194123bec30c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
import sys | |
from http.server import HTTPServer, BaseHTTPRequestHandler | |
if len(sys.argv)-1 != 2: | |
print(""" | |
Usage: {} <port_number> <url> | |
""".format(sys.argv[0])) | |
sys.exit() | |
class Redirect(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(307) | |
self.send_header('Location', sys.argv[2]) | |
self.end_headers() | |
HTTPServer(("", int(sys.argv[1])), Redirect).serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment