mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-11 05:52:33 +08:00
specify a custom web browser to launch
instead of launching the default browser, pass a custom file path. also include a csv of command line flags like incognito,start-maximized
This commit is contained in:
parent
62efc78a4b
commit
f0e24a583d
@ -94,6 +94,9 @@ parser.add_argument("--windows-standalone-build", action="store_true", help="Win
|
||||
|
||||
parser.add_argument("--disable-metadata", action="store_true", help="Disable saving prompt metadata in files.")
|
||||
|
||||
parser.add_argument("--custom-browser-path", type=str, help="Path to custom browser instead of platform default, ex: c:/chrome.exe")
|
||||
parser.add_argument("--custom-browser-args-csv", type=str, help="Args to pass to browser, ex: \"incognito,start-maximized\"")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.windows_standalone_build:
|
||||
|
||||
@ -407,3 +407,19 @@ class ProgressBar:
|
||||
|
||||
def update(self, value):
|
||||
self.update_absolute(self.current + value)
|
||||
|
||||
def launch_custom_web_browser(args, address, port):
|
||||
import webbrowser
|
||||
custom_browser = webbrowser.GenericBrowser(args.custom_browser_path)
|
||||
|
||||
#If the user has supplied custom browser args
|
||||
if args.custom_browser_args_csv:
|
||||
|
||||
#args.browser_args_csv is a csv, split it into a list, prepend "--" to each arg and append to custom_browser.args
|
||||
for arg in args.custom_browser_args_csv.split(","):
|
||||
custom_browser.args.append("--" + arg)
|
||||
|
||||
webbrowser.register('custom_browser', None, custom_browser)
|
||||
customBrowser = webbrowser.get('custom_browser')
|
||||
print(f"Launching custom browser at " + args.custom_browser_path)
|
||||
customBrowser.open(f"http://{address}:{port}")
|
||||
11
main.py
11
main.py
@ -180,7 +180,16 @@ if __name__ == "__main__":
|
||||
import webbrowser
|
||||
if os.name == 'nt' and address == '0.0.0.0':
|
||||
address = '127.0.0.1'
|
||||
webbrowser.open(f"http://{address}:{port}")
|
||||
|
||||
#If the user has supplied a custom browser path, use that instead of the default browser
|
||||
if args.custom_browser_path:
|
||||
if os.path.isfile(args.custom_browser_path):
|
||||
comfy.utils.launch_custom_web_browser(args, address, port)
|
||||
else:
|
||||
print(f"Custom browser path does not exist: {args.custom_browser_path}")
|
||||
else:
|
||||
webbrowser.open(f"http://{address}:{port}")
|
||||
|
||||
call_on_start = startup_server
|
||||
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user