import os
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingMixIn


class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
    daemon_threads = True


class SimpleHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"Target reached!")

    def log_message(self, format, *args):
        return


if __name__ == "__main__":
    HOST = os.getenv("HOST", "0.0.0.0")
    PORT = int(os.getenv("PORT", 9000))
    addr = (HOST, PORT)
    server = ThreadedHTTPServer(addr, SimpleHandler)
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        pass
