be more flexible about opening any browser
This commit is contained in:
parent
a0da2c25db
commit
46aa7b45f5
1 changed files with 5 additions and 1 deletions
|
@ -147,13 +147,17 @@ class UiServer:
|
|||
if config.open_browser and config.open_browser != "False":
|
||||
logging.info("Opening browser: %s...", config.open_browser)
|
||||
import webbrowser
|
||||
ui_ip = config.ui_ip if config.ui_ip != "*" else "127.0.0.1"
|
||||
url = f'http://{ui_ip}:{config.ui_port}/{config.homepage}'
|
||||
try:
|
||||
if config.open_browser == "default_browser":
|
||||
browser = webbrowser.get()
|
||||
else:
|
||||
browser = webbrowser.get(config.open_browser)
|
||||
url = "http://%s:%s/%s" % (config.ui_ip if config.ui_ip != "*" else "127.0.0.1", config.ui_port, config.homepage)
|
||||
gevent.spawn_later(0.3, browser.open, url, new=2)
|
||||
except webbrowser.Error as err:
|
||||
import subprocess
|
||||
subprocess.Popen([config.open_browser, url])
|
||||
except Exception as err:
|
||||
print("Error starting browser: %s" % err)
|
||||
|
||||
|
|
Loading…
Reference in a new issue