From 028bfc0cd050a817f48a797541c488d2985de6e9 Mon Sep 17 00:00:00 2001 From: JP Flouret Date: Tue, 19 Mar 2024 13:56:15 -0700 Subject: [PATCH] Add /healthz endpoint --- server.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.py b/server.py index 18b5559..c5deab2 100644 --- a/server.py +++ b/server.py @@ -11,11 +11,23 @@ class MyServer(BaseHTTPRequestHandler): def do_GET(self): self.server_version = 'Teapot/1.0.0' self.sys_version = 'Coffee/1.0.0' + if self.path == '/healthz': + self.healthz() + else: + self.teapot() + + def teapot(self): self.send_response(418) self.send_header("Content-type", "text/plain; charset=utf-8") self.end_headers() self.wfile.write(bytes("I'm a teapot.\n", "utf-8")) + def healthz(self): + self.send_response(200) + self.send_header("Content-type", "text/plain; charset=utf-8") + self.end_headers() + self.wfile.write(bytes("OK\n", "utf-8")) + if __name__ == "__main__": webServer = HTTPServer((bindAddress, serverPort), MyServer)