from http.server import HTTPServer, SimpleHTTPRequestHandler import ssl server_address = ('', 443) certfile = 'cert.pem' keyfile = 'key.pem' httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, certfile=certfile, keyfile=keyfile, server_side=True) print("Server is running at https://localhost:443/") httpd.serve_forever()