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