默认不打开浏览器,太麻烦了,每次部署上服务器都要关
This commit is contained in:
@ -327,13 +327,13 @@ class ChatBot(ChatBotFrame):
|
|||||||
self.submit_start.click(fn=agent_main, inputs=self.auto_input_combo, outputs=self.auto_output_combo)
|
self.submit_start.click(fn=agent_main, inputs=self.auto_input_combo, outputs=self.auto_output_combo)
|
||||||
|
|
||||||
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
||||||
def auto_opentab_delay(self):
|
def auto_opentab_delay(self, is_open=False):
|
||||||
import threading, webbrowser, time
|
import threading, webbrowser, time
|
||||||
|
|
||||||
print(f"如果浏览器没有自动打开,请复制并转到以下URL:")
|
print(f"如果浏览器没有自动打开,请复制并转到以下URL:")
|
||||||
print(f"\t(亮色主题): http://localhost:{PORT}")
|
print(f"\t(亮色主题): http://localhost:{PORT}")
|
||||||
print(f"\t(暗色主题): {self.__url}/?__theme=dark")
|
print(f"\t(暗色主题): {self.__url}/?__theme=dark")
|
||||||
|
if is_open:
|
||||||
def open():
|
def open():
|
||||||
time.sleep(2) # 打开浏览器
|
time.sleep(2) # 打开浏览器
|
||||||
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__theme=dark")
|
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__theme=dark")
|
||||||
|
|||||||
Reference in New Issue
Block a user