-
-
Save hotplugin0x01/81de86d96d9734d3a7cf3633dbeca782 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