#!/usr/bin/env python3
"""HTTPS file server for the Omarchy ISO, TLS via Let's Encrypt."""
import http.server, ssl, os, functools

DIR = "/root/loot/isos"
CERT = "/etc/letsencrypt/live/dl.milesmclenon.com/fullchain.pem"
KEY = "/etc/letsencrypt/live/dl.milesmclenon.com/privkey.pem"

class Handler(http.server.SimpleHTTPRequestHandler):
    def log_message(self, fmt, *args):
        pass  # quiet

os.chdir(DIR)
handler = functools.partial(Handler, directory=DIR)

ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ctx.load_cert_chain(CERT, KEY)

httpd = http.server.ThreadingHTTPServer(("0.0.0.0", 443), handler)
httpd.socket = ctx.wrap_socket(httpd.socket, server_side=True)
print("HTTPS serving on :443 ->", DIR, flush=True)
httpd.serve_forever()
