Skip to content

Commit

Permalink
Add /healthz endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jpflouret committed Mar 19, 2024
1 parent 48283c6 commit 028bfc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 028bfc0

Please sign in to comment.