From fc0b9a12683516991c28635e89684813605fd9da Mon Sep 17 00:00:00 2001 From: nihonium Date: Thu, 31 Oct 2024 23:05:00 +0300 Subject: [PATCH] initial commit --- Dockerfile | 9 +++++++++ src/server.py | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Dockerfile create mode 100644 src/server.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a268910 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.11-slim + +WORKDIR /server + +COPY src/server.py . + +EXPOSE 8888 + +CMD ["python", "server.py"] diff --git a/src/server.py b/src/server.py new file mode 100644 index 0000000..ce2a5ff --- /dev/null +++ b/src/server.py @@ -0,0 +1,23 @@ +from http.server import BaseHTTPRequestHandler, HTTPServer + +class RequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + if self.path == '/healthz': + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(b'200 OK\n') + else: + self.send_response(404) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(b'Not Found\n') + +def run(server_class=HTTPServer, handler_class=RequestHandler, port=8888): + server_address = ('', port) + httpd = server_class(server_address, handler_class) + print(f'Starting http server on port {port}') + httpd.serve_forever() + +if __name__ == "__main__": + run()