-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#145] Create health endpoint in eppo-librarian
- Loading branch information
1 parent
e0d78fc
commit 5ec17ed
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HealthCheckHandler(BaseHTTPRequestHandler): | ||
def do_GET(self): | ||
if self.path == "/health": | ||
self.send_response(200) | ||
self.send_header("Content-type", "application/json") | ||
self.end_headers() | ||
self.wfile.write(b'{"status": "ok"}') | ||
else: | ||
self.send_response(404) | ||
self.end_headers() | ||
|
||
|
||
def run(server_class=HTTPServer, handler_class=HealthCheckHandler, port=9001): | ||
server_address = ("", port) | ||
httpd = server_class(server_address, handler_class) | ||
logger.info(f"Starting httpd server on port {port}") | ||
httpd.serve_forever() |