From 26a84f9c73983c0c044933f8697f57a42adac8c0 Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Sat, 20 Jan 2024 22:15:10 +0800 Subject: [PATCH] =?UTF-8?q?start=20falsk=20=E6=B7=BB=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=98=AF=E5=90=A6=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/server.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pywxdump/server.py b/pywxdump/server.py index 4951072..08bf6e1 100644 --- a/pywxdump/server.py +++ b/pywxdump/server.py @@ -12,7 +12,7 @@ import time def start_falsk(merge_path="", msg_path="", micro_path="", media_path="", wx_path="", key="", my_wxid="", port=5000, - online=False, debug=False): + online=False, debug=False,isopenBrowser=True): """ 启动flask :param merge_path: 合并后的数据库路径 @@ -75,21 +75,21 @@ def start_falsk(merge_path="", msg_path="", micro_path="", media_path="", wx_pat save_session(session_file, "test", my_wxid) app.register_blueprint(api) - - try: - # 自动打开浏览器 - url = f"http://127.0.0.1:{port}/" - # 根据操作系统使用不同的命令打开默认浏览器 - if sys.platform.startswith('darwin'): # macOS - subprocess.call(['open', url]) - elif sys.platform.startswith('win'): # Windows - subprocess.call(['start', url], shell=True) - elif sys.platform.startswith('linux'): # Linux - subprocess.call(['xdg-open', url]) - else: - print("Unsupported platform, can't open browser automatically.") - except Exception as e: - pass + if isopenBrowser: + try: + # 自动打开浏览器 + url = f"http://127.0.0.1:{port}/" + # 根据操作系统使用不同的命令打开默认浏览器 + if sys.platform.startswith('darwin'): # macOS + subprocess.call(['open', url]) + elif sys.platform.startswith('win'): # Windows + subprocess.call(['start', url], shell=True) + elif sys.platform.startswith('linux'): # Linux + subprocess.call(['xdg-open', url]) + else: + print("Unsupported platform, can't open browser automatically.") + except Exception as e: + pass def is_port_in_use(host, port): import socket