Skip to content

Instantly share code, notes, and snippets.

@random-robbie
Created May 12, 2020 15:09
Show Gist options
  • Save random-robbie/36ef1d031d7bc53e48050e5f14863767 to your computer and use it in GitHub Desktop.
Save random-robbie/36ef1d031d7bc53e48050e5f14863767 to your computer and use it in GitHub Desktop.
#!/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