From 7b790ef609748a5ceda7cfcae7896ca1bdb38dfa Mon Sep 17 00:00:00 2001 From: sansen Date: Thu, 23 Jul 2026 17:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client_app.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client_app.py b/client_app.py index 2531747..9ea334f 100644 --- a/client_app.py +++ b/client_app.py @@ -2,7 +2,7 @@ import json from fastapi import FastAPI, HTTPException, Header, Form, Request from fastapi.responses import JSONResponse from fastapi.middleware.cors import CORSMiddleware - +from loguru import logger from parser import * app = FastAPI() @@ -19,9 +19,9 @@ app.add_middleware( @app.post("/convert/start") async def convert_str( - request: Request, - content: str = Form(...), # ✅ 改为接收 x-www-form-urlencoded 参数 - Authorization: str = Header(None) + request: Request, + content: str = Form(...), # ✅ 改为接收 x-www-form-urlencoded 参数 + Authorization: str = Header(None) ): """ 带调试信息的转换接口 (支持 x-www-form-urlencoded) @@ -32,10 +32,10 @@ async def convert_str( try: res = convert_text(content) - print(f"转换结果: {json.dumps(res, ensure_ascii=False, indent=2)}") + logger.info(f"转换结果: {json.dumps(res, ensure_ascii=False, indent=2)}") return JSONResponse(content={"code": 0, "result": res}) except Exception as e: - print(f"转换异常: {str(e)}") + logger.error(f"转换异常: {str(e)}") return JSONResponse( content={"code": 500, "result": f"转换服务异常: {str(e)}"}, status_code=500