From 9a95dd7e015bcce9c09671472eddf52d7db0c40b Mon Sep 17 00:00:00 2001 From: Bobbi Webber-Manners Date: Thu, 18 Jun 2020 23:19:49 -0400 Subject: [PATCH] Hack to make links work properly within a page!!!! --- dehttps-proxy.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dehttps-proxy.py b/dehttps-proxy.py index 7918b37..205c85a 100755 --- a/dehttps-proxy.py +++ b/dehttps-proxy.py @@ -14,7 +14,16 @@ import http.server, socketserver import requests, sys -PORT = 8000 +baseurl = '' + +PORT = 8001 + +def isFullyQualified(name): + tlds = [ '.com', '.org', '.net', '.gov', '.ca', '.io', '.uk'] + for t in tlds: + if name.endswith(t): + return True + return False class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): @@ -22,7 +31,12 @@ class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): http.server.SimpleHTTPRequestHandler.__init__(self, req, client_addr, server) def do_GET(self): - url = 'https:/' + self.path + global baseurl + if isFullyQualified(self.path): + url = 'https:/' + self.path + baseurl = url + else: + url = baseurl + self.path print('Getting {} ...'.format(url)) err = False try: @@ -36,6 +50,7 @@ class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): self.end_headers() self.wfile.write(file.content) +print("dehttps-proxy: listening on port {} ...".format(PORT)) handler = MyHTTPRequestHandler httpd = socketserver.TCPServer(("", PORT), handler) httpd.serve_forever()