in walkthroughs/howto-k8s-mtls-file-based/feapp/serve.py [0:0]
def do_GET(self):
if self.path == '/ping':
self.send_response(200)
self.end_headers()
return
try:
print('Trying to hit ' + COLOR_HOST.split(':')[0])
print(socket.gethostbyname(COLOR_HOST.split(':')[0]))
req = Request(f'http://{COLOR_HOST}')
cool_header = self.headers.get('color_header')
if cool_header is not None:
req.add_header('color_header', cool_header)
res = urlopen(req)
self.send_response(200)
self.end_headers()
self.wfile.write(res.read())
except HTTPError as e:
print(f'[ERROR] {e}')
self.send_error(e.code, e.reason)
except Exception as e:
print(f'[ERROR] {e}')
self.send_error(500, b'Something really bad happened')