Update start_httpd
This commit is contained in:
parent
7b3e66514a
commit
50eddb5731
|
@ -20,9 +20,10 @@ def copy_file(src, dst):
|
||||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
|
||||||
# Функция для запуска веб-сервера
|
# Функция для запуска веб-сервера
|
||||||
def start_httpd(directory: Path, port: int = 8000):
|
def start_httpd(directory: Path, port: int = 8000, interface: str = 'localhost'):
|
||||||
print(f"Listen on port {port}, serving from {directory}...")
|
print(f"Listen on http://{interface}:{port}, serving from '{directory}' directory...")
|
||||||
handler = partial(SimpleHTTPRequestHandler, directory=directory)
|
handler = partial(SimpleHTTPRequestHandler, directory=directory)
|
||||||
httpd = HTTPServer(('localhost', port), handler)
|
httpd = HTTPServer((interface, port), handler)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
Loading…
Reference in New Issue