feat: add initial health-check application
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == "/health":
|
||||
status = 200
|
||||
body = {"status": "ok"}
|
||||
elif self.path == "/":
|
||||
status = 200
|
||||
body = {
|
||||
"application": "devops-platform",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
else:
|
||||
status = 404
|
||||
body = {"error": "not found"}
|
||||
|
||||
payload = json.dumps(body).encode("utf-8")
|
||||
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(payload)))
|
||||
self.end_headers()
|
||||
self.wfile.write(payload)
|
||||
|
||||
def log_message(self, format, *args):
|
||||
print(f"{self.client_address[0]} - {format % args}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = HTTPServer(("127.0.0.1", 8000), Handler)
|
||||
print("Listening on http://127.0.0.1:8000")
|
||||
server.serve_forever()
|
||||
Reference in New Issue
Block a user