Update start_httpd

This commit is contained in:
Digital Studium 2023-07-23 16:11:26 +03:00
parent 7b3e66514a
commit 50eddb5731
1 changed files with 4 additions and 3 deletions

View File

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