Add support for IPv6

http.server supports IPv6, but the address has to be processed by _get_best_family
This commit is contained in:
chaihahaha
2025-02-23 02:13:11 +08:00
committed by GitHub
parent 09b641aaa7
commit 12d1e968cc

View File

@@ -8,7 +8,7 @@ import time
import uuid
import warnings
from dataclasses import dataclass, field
from http.server import BaseHTTPRequestHandler, HTTPServer
from http.server import BaseHTTPRequestHandler, HTTPServer, _get_best_family
from pathlib import Path
from typing import (
Any,
@@ -694,6 +694,7 @@ def run(
):
server_address = (host, port)
prompt_cache = PromptCache()
server_class.address_family, server_address = _get_best_family(*server_address)
httpd = server_class(
server_address,
lambda *args, **kwargs: handler_class(