import http.server, ssl, os
os.chdir(os.path.dirname(os.path.abspath(__file__)))


class H(http.server.SimpleHTTPRequestHandler):
    def log_message(self, fmt, *a):
        with open("/tmp/tls.log", "a") as f:
            f.write("%s %s\n" % (self.address_string(), fmt % a))


srv = http.server.HTTPServer(("0.0.0.0", 8899), H)
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ctx.load_cert_chain("cert.pem", "key.pem")
srv.socket = ctx.wrap_socket(srv.socket, server_side=True)
srv.serve_forever()
