From 7f667f4dc2e63285a954cea108bbe64cf7cb8977 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sat, 3 May 2025 01:53:00 +0800 Subject: [PATCH] fix port --- app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.py b/app.py index ec20d90..2e3dd9b 100644 --- a/app.py +++ b/app.py @@ -171,4 +171,11 @@ async def shutdown_event(): if __name__ == '__main__': import uvicorn port = os.getenv("XHS_API_PORT", 5005) + # 不是数字的话转为 int + try: + port = int(port) + except ValueError: + print(f"Invalid port number: {port}. Using default port 5005.") + port = 5005 + # 启动 FastAPI 应用 uvicorn.run(app, host="0.0.0.0", port=port) \ No newline at end of file