From a10d9d45971c1e4bf9c9142ce0ca532257274753 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 26 Sep 2019 22:56:40 +0200 Subject: [PATCH] Document on how to use IPv6 with the http server --- .../contents.lr | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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