From 607fa53553b1f8b08eca88e3ea1d41d1e203062d Mon Sep 17 00:00:00 2001 From: weiweiw <14335254+weiweiw22@user.noreply.gitee.com> Date: Fri, 21 Jun 2024 13:28:47 +0800 Subject: [PATCH] first commit --- .DS_Store | Bin 12292 -> 12292 bytes webui_pages/utils.py | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 604f0e101c57b2277f514c8e7ee1c7d38096090c..76e2ff12d9b1dc34dbdaaab451c7c1f6d917426b 100644 GIT binary patch delta 129 zcmZokXi1ph&nUJrU^hP_?_>cMmCXhMj9lW}4CM@|3`q>744Dk^3TVA!ZMTp M3#n|rub|2g02`tqegFUf delta 45 zcmZokXi1ph&nU7nU^hP__hbPUmCXhMj9i;dq_4AVY+z=b%&pKnxm3x0^L+(XegH(D B4iNwV diff --git a/webui_pages/utils.py b/webui_pages/utils.py index e57478c..6cca8d3 100644 --- a/webui_pages/utils.py +++ b/webui_pages/utils.py @@ -137,10 +137,13 @@ class ApiRequest: try: if chunk.startswith("data: "): data = json.loads(chunk[6:-2]) + pprint(data,depth=1) elif chunk.startswith(":"): # skip sse comment line continue else: data = json.loads(chunk) + pprint(data,depth=1) + #print(f"{data}") yield data except Exception as e: msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。" @@ -173,17 +176,21 @@ class ApiRequest: try: if chunk.startswith("data: "): data = json.loads(chunk[6:-2]) + print("ret_sync, data = json.loads(chunk[6:-2])") + pprint(data,depth=1) elif chunk.startswith(":"): # skip sse comment line continue else: + # print(f"{chunk}") data = json.loads(chunk) + print("ret_sync, data = json.loads(chunk)") + pprint(data,depth=1) yield data except Exception as e: msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。" logger.error(f'{e.__class__.__name__}: {msg}', exc_info=e if log_verbose else None) else: - # print(chunk, end="", flush=True) yield chunk except httpx.ConnectError as e: msg = f"无法连接API服务器,请确认 ‘api.py’ 已正常启动。({e})"