Spaces:
Paused
Paused
Update proxy.py
Browse files
proxy.py
CHANGED
@@ -9,18 +9,16 @@ PROXY_PORT = 8080
|
|
9 |
class ProxyRequestHandler(http.server.SimpleHTTPRequestHandler):
|
10 |
def do_GET(self):
|
11 |
# Forward GET request to the proxy port with "/site" appended to the path
|
12 |
-
|
13 |
-
|
14 |
-
url = 'http://localhost:{}{}'.format(PROXY_PORT, '/site' + self.path)
|
15 |
else:
|
16 |
-
|
17 |
print("path={}, url={}".format(self.path,url))
|
18 |
headers = dict(self.headers)
|
19 |
del headers['Host'] # Remove "Host" header to avoid "HTTP/1.1 400 Bad Request" error
|
20 |
conn = http.client.HTTPConnection('localhost', PROXY_PORT)
|
21 |
conn.request('GET', url, headers=headers)
|
22 |
response = conn.getresponse()
|
23 |
-
|
24 |
# Send the proxy response back to the client
|
25 |
self.send_response(response.status)
|
26 |
for header, value in response.getheaders():
|
|
|
9 |
class ProxyRequestHandler(http.server.SimpleHTTPRequestHandler):
|
10 |
def do_GET(self):
|
11 |
# Forward GET request to the proxy port with "/site" appended to the path
|
12 |
+
if self.path == '/' or self.path.startswith("/?"):
|
13 |
+
url = 'http://localhost:{}{}'.format(PROXY_PORT, '/site' + self.path)
|
|
|
14 |
else:
|
15 |
+
url = 'http://localhost:{}{}'.format(PROXY_PORT, self.path)
|
16 |
print("path={}, url={}".format(self.path,url))
|
17 |
headers = dict(self.headers)
|
18 |
del headers['Host'] # Remove "Host" header to avoid "HTTP/1.1 400 Bad Request" error
|
19 |
conn = http.client.HTTPConnection('localhost', PROXY_PORT)
|
20 |
conn.request('GET', url, headers=headers)
|
21 |
response = conn.getresponse()
|
|
|
22 |
# Send the proxy response back to the client
|
23 |
self.send_response(response.status)
|
24 |
for header, value in response.getheaders():
|