From 46eba1f39958a2b7cb7df3069d0266b075bb3a3e Mon Sep 17 00:00:00 2001 From: Chuan Hu <51039745+GaiZhenbiao@users.noreply.github.com> Date: Tue, 28 Mar 2023 22:47:30 +0800 Subject: [PATCH] Improve the way to open webbrowser --- main.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/main.py b/main.py index c9af1a1..eecd126 100644 --- a/main.py +++ b/main.py @@ -89,15 +89,5 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: except: pass -# 延迟函数, 做一些准备工作, 最后尝试打开浏览器 -def auto_opentab_delay(): - import threading, webbrowser, time - print(f"URL http://localhost:{PORT}") - def open(): time.sleep(2) - webbrowser.open_new_tab(f'http://localhost:{PORT}') - t = threading.Thread(target=open) - t.daemon = True; t.start() - -auto_opentab_delay() demo.title = "ChatGPT 学术优化" -demo.queue().launch(server_name="0.0.0.0", share=True, server_port=PORT) +demo.queue().launch(server_name="0.0.0.0", share=True, server_port=PORT, inbrowser=True)