INNER CODE UNIT · Python
start_local_server
satoshikawato/gbdraw · gbdraw/cli.py:54
def start_local_server(directory: str):
"""
Starts a local HTTP server to serve the gbdraw web UI.
"""
port = find_free_port()
handler = partial(IsolatedSimpleHTTPRequestHandler, directory=directory)
try:
httpd = socketserver.TCPServer(("127.0.0.1", port), handler)
except OSError as e:
print(f"Error starting server: {e}", file=sys.stderr)
return
url = f"http://localhost:{port}"
print(f"✅ Local server started at: {url}")
print(f"📂 Serving UI from: {directory}")