Improve the way to open webbrowser
This commit is contained in:
parent
5a6877f9fa
commit
46eba1f399
12
main.py
12
main.py
@ -89,15 +89,5 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|||||||
except: pass
|
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.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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user