import http.server
import ssl

# Define server address and handler
server_address = ('localhost', 443)
handler = http.server.SimpleHTTPRequestHandler

# Create the HTTP server
httpd = http.server.HTTPServer(server_address, handler)

# Set up SSL context (modern way)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile='mycert.crt', keyfile='mycert.key')

# Wrap the socket
httpd.socket = context.wrap_socket(httpd.socket, server_side=True)

print("Serving on https://localhost:443")
httpd.serve_forever()
