Skip to content

Instantly share code, notes, and snippets.

@alecandido
Created March 9, 2024 23:14
Show Gist options
  • Save alecandido/d60b559c71a9f7bb1709d16110f71a59 to your computer and use it in GitHub Desktop.
Save alecandido/d60b559c71a9f7bb1709d16110f71a59 to your computer and use it in GitHub Desktop.
import http.server
import ssl
import socket
class HTTPServerV6(http.server.HTTPServer):
address_family = socket.AF_INET6
httpd = HTTPServerV6(("::", 443), http.server.SimpleHTTPRequestHandler)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile="cert.pem", keyfile="key.pem")
httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
httpd.serve_forever()
@alecandido
Copy link
Author

A simple HTTPS server supporting IPv6 on arbitrary address.

Working with Python 3.11 (avoiding deprecated features).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment