From d483b87172a3b5a17cb75e112759a8ddf329e00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Lond=C3=B6g=C3=A5rd?= Date: Tue, 4 Jul 2023 19:19:09 +0200 Subject: [PATCH] fix: default to localhost on WSL (#180) * fix: Only reload necessary files & default to localhost on WSL * fix: default WSL into localhost URL * fix: remove uname * revert: reload * fix: replace variable with branching * Update __main__.py * fix: remove debug code Co-authored-by: Maarten Breddels --------- Co-authored-by: Maarten Breddels --- solara/__main__.py | 1 + solara/server/settings.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/solara/__main__.py b/solara/__main__.py index ff8a4edb5..02aa7a4a6 100644 --- a/solara/__main__.py +++ b/solara/__main__.py @@ -326,6 +326,7 @@ def open_browser(): if open: threading.Thread(target=open_browser, daemon=True).start() + rich.print(f"Solara server is starting at {url}") if log_level is not None: diff --git a/solara/server/settings.py b/solara/server/settings.py index 4a62a39e4..fdcbd3d09 100644 --- a/solara/server/settings.py +++ b/solara/server/settings.py @@ -4,6 +4,7 @@ import uuid from enum import Enum from pathlib import Path +import re from typing import Optional import pydantic @@ -120,7 +121,9 @@ class Config: HOST_DEFAULT = os.environ.get("HOST", "localhost") -if "arm64-apple-darwin" in HOST_DEFAULT: # conda activate script +is_mac_os_conda = "arm64-apple-darwin" in HOST_DEFAULT +is_wsl_windows = re.match(r".*?-w1[0-9]", HOST_DEFAULT) +if is_mac_os_conda or is_wsl_windows: HOST_DEFAULT = "localhost"