import http.server,ssl,os
ROOT=os.path.dirname(os.path.abspath(__file__))
class Handler(http.server.BaseHTTPRequestHandler):
 def do_GET(self):
  body=b'''<!doctype html><html><head><title>Local HTTPS controller</title></head><body style="font:20px system-ui;background:#edf3f7;color:#163348;padding:48px"><h1>Local HTTPS controller</h1><p>Secure connection established.</p><p>This synthetic local service uses a self-signed certificate.</p><p id="status">Controller status: Online</p></body></html>'''
  self.send_response(200);self.send_header('Content-Type','text/html');self.end_headers();self.wfile.write(body)
 def log_message(self,*args):pass
s=http.server.HTTPServer(('127.0.0.1',int(os.environ.get('SERVICE_PORT','18443'))),Handler)
c=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER);c.load_cert_chain(os.path.join(ROOT,os.environ.get('SERVICE_CERT','cert.pem')),os.path.join(ROOT,os.environ.get('SERVICE_KEY','key.pem')));s.socket=c.wrap_socket(s.socket,server_side=True);s.serve_forever()
