mirror of
https://github.com/Usagi-org/ai-goofish-monitor.git
synced 2025-11-25 11:29:41 +08:00
支持服务端口自定义
This commit is contained in:
@@ -69,6 +69,9 @@ pip install -r requirements.txt
|
||||
|
||||
# 爬虫是否以无头模式运行 (true/false)。遇到滑动验证码时,可设为 false
|
||||
RUN_HEADLESS=true
|
||||
|
||||
# 服务端口自定义 不配置默认8000
|
||||
SERVER_PORT=8000
|
||||
```
|
||||
|
||||
2. **获取登录状态 (重要!)**: 为了让爬虫能够以登录状态访问闲鱼,**必须先运行一次登录脚本**以生成会话状态文件。
|
||||
|
||||
@@ -471,8 +471,17 @@ async def shutdown_event():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 从 .env 文件加载环境变量
|
||||
config = dotenv_values(".env")
|
||||
|
||||
# 获取服务器端口,如果未设置则默认为 8000
|
||||
server_port = int(config.get("SERVER_PORT", 8000))
|
||||
|
||||
# 设置默认编码
|
||||
env = os.environ.copy()
|
||||
env["PYTHONIOENCODING"] = "utf-8"
|
||||
print("启动 Web 管理界面,请在浏览器访问 http://127.0.0.1:8000")
|
||||
|
||||
print(f"启动 Web 管理界面,请在浏览器访问 http://127.0.0.1:{server_port}")
|
||||
|
||||
uvicorn.run(app, host="127.0.0.1", port=8000)
|
||||
# 启动 Uvicorn 服务器
|
||||
uvicorn.run(app, host="127.0.0.1", port=server_port)
|
||||
|
||||
Reference in New Issue
Block a user