This commit is contained in:
熊潇 2025-05-03 01:53:00 +08:00
parent f5561f4fa9
commit 7f667f4dc2

7
app.py
View File

@ -171,4 +171,11 @@ async def shutdown_event():
if __name__ == '__main__': if __name__ == '__main__':
import uvicorn import uvicorn
port = os.getenv("XHS_API_PORT", 5005) 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) uvicorn.run(app, host="0.0.0.0", port=port)