diff --git a/content/u/blog/how-to-enable-ipv6-in-applications/contents.lr b/content/u/blog/how-to-enable-ipv6-in-applications/contents.lr index 7032118..70e5b9e 100644 --- a/content/u/blog/how-to-enable-ipv6-in-applications/contents.lr +++ b/content/u/blog/how-to-enable-ipv6-in-applications/contents.lr @@ -142,6 +142,28 @@ vrrp_instance router_internal_ipv4 { } ``` +## How to enable IPv6 in the Python HTTP Server + +If you are coding in python and you want your HTTP server to listen on +IPv6, you can inherit from HTTPServer and set the address family to +*AF_INET6* as follows: + +``` +from http.server import HTTPServer + +class HTTPServerV6(HTTPServer): + address_family = socket.AF_INET6 + +if __name__ == '__main__': + myv6server = HTTPServerV6 + +``` +For more details on how to use the HTTPServer in general, +checkout +[this stackoverflow post](https://stackoverflow.com/questions/23264569/python-3-x-basehttpserver-or-http-server). + +Thanks to cvmiller for this hint! + ## How to enable IPv6 in Redhat Linux While Red Hat is not specifically an application, we still wanted