diff --git a/Dockerfile b/Dockerfile index a89c77f..5de8794 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,10 +49,10 @@ COPY . . # 创建临时目录 RUN mkdir -p /tmp/web_captures -EXPOSE 5000 +EXPOSE 16025 # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:5000/health || exit 1 + CMD curl -f http://localhost:16025/health || exit 1 -CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "--timeout", "120", "app:app"] \ No newline at end of file +CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "--timeout", "120", "app:app"] \ No newline at end of file diff --git a/README.md b/README.md index 291102e..40e365a 100644 --- a/README.md +++ b/README.md @@ -104,18 +104,18 @@ API 信息接口 ```bash # 基础截图 -curl -X POST http://localhost:5000/api/capture \ +curl -X POST http://localhost:16025/api/capture \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com", "action": "screenshot"}' \ --output screenshot.png # 提取HTML -curl -X POST http://localhost:5000/api/capture \ +curl -X POST http://localhost:16025/api/capture \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com", "action": "html"}' # 滚动加载后全页截图 -curl -X POST http://localhost:5000/api/capture \ +curl -X POST http://localhost:16025/api/capture \ -H "Content-Type: application/json" \ -d '{ "url": "https://news.ycombinator.com", @@ -127,7 +127,7 @@ curl -X POST http://localhost:5000/api/capture \ --output full_page.png # 自定义视口 -curl -X POST http://localhost:5000/api/capture \ +curl -X POST http://localhost:16025/api/capture \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com", @@ -144,7 +144,7 @@ import requests # 截图 response = requests.post( - 'http://localhost:5000/api/capture', + 'http://localhost:16025/api/capture', json={ 'url': 'https://example.com', 'action': 'screenshot' @@ -155,7 +155,7 @@ with open('screenshot.png', 'wb') as f: # 提取HTML response = requests.post( - 'http://localhost:5000/api/capture', + 'http://localhost:16025/api/capture', json={ 'url': 'https://example.com', 'action': 'html' @@ -169,7 +169,7 @@ print(html) ```javascript // 截图 -const response = await fetch('http://localhost:5000/api/capture', { +const response = await fetch('http://localhost:16025/api/capture', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ @@ -182,7 +182,7 @@ const response = await fetch('http://localhost:5000/api/capture', { const blob = await response.blob(); // 提取HTML -const response = await fetch('http://localhost:5000/api/capture', { +const response = await fetch('http://localhost:16025/api/capture', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ @@ -199,7 +199,7 @@ console.log(data.html); ### 使用 Gunicorn ```bash -gunicorn -w 4 -b 0.0.0.0:5000 app:app +gunicorn -w 4 -b 0.0.0.0:16025 app:app ``` ### 使用 Systemd 服务 @@ -230,12 +230,12 @@ RUN playwright install chromium --with-deps COPY . . EXPOSE 5000 -CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"] +CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "app:app"] ``` ```bash docker build -t web-capture-api . -docker run -p 5000:5000 web-capture-api +docker run -p 16025:16025 web-capture-api ``` ## 性能优化 diff --git a/app.py b/app.py index c18246b..b84107d 100644 --- a/app.py +++ b/app.py @@ -397,5 +397,5 @@ if __name__ == '__main__': print(" agent-browser: npm install -g agent-browser && agent-browser install") print(" playwright: pip install playwright && playwright install chromium") - print("\n🚀 Server running on http://0.0.0.0:5000") - app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file + print("\n🚀 Server running on http://0.0.0.0:16025") + app.run(host='0.0.0.0', port=16025, debug=True) \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index 5bd69a9..66621f9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -23,4 +23,4 @@ echo "运行方式:" echo " 开发模式: python3.12 app.py" echo " 生产模式: gunicorn -w 4 -b 0.0.0.0:5000 app:app" echo "" -echo "访问地址: http://localhost:5000" \ No newline at end of file +echo "访问地址: http://localhost:16025" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 00fa23e..f70625f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,14 +6,14 @@ services: image: web-capture-api:latest container_name: web-capture-api ports: - - "5000:5000" + - "16025:16025" environment: - TZ=Asia/Shanghai volumes: - ./captures:/tmp/web_captures restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:5000/health"] + test: ["CMD", "curl", "-f", "http://localhost:16025/health"] interval: 30s timeout: 10s retries: 3 diff --git a/install.sh b/install.sh index d1e96b0..18a36ed 100755 --- a/install.sh +++ b/install.sh @@ -110,7 +110,7 @@ echo " cd $(pwd)" echo " $PYTHON app.py" echo "" echo "📖 访问地址:" -echo " http://localhost:5000" +echo " http://localhost:16025" echo "" echo "📚 API 文档:" -echo " http://localhost:5000/api" \ No newline at end of file +echo " http://localhost:16025/api" \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index de67b77..607fd14 100644 --- a/templates/index.html +++ b/templates/index.html @@ -405,7 +405,7 @@ submitBtn.disabled = true; try { - const response = await fetch('/api/capture', { + const response = await fetch('http://localhost:16025/api/capture', { method: 'POST', headers: { 'Content-Type': 'application/json' diff --git a/test_api.py b/test_api.py index 9f52d6a..a512a0d 100755 --- a/test_api.py +++ b/test_api.py @@ -7,7 +7,7 @@ import requests import json import sys -API_URL = "http://localhost:5000" +API_URL = "http://localhost:16025" def test_health(): diff --git a/web-capture-api.service b/web-capture-api.service index 3ae53d4..926de94 100644 --- a/web-capture-api.service +++ b/web-capture-api.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=openclaw WorkingDirectory=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api -ExecStart=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api/venv/bin/gunicorn -w 4 -b 0.0.0.0:5000 app:app +ExecStart=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api/venv/bin/gunicorn -w 4 -b 0.0.0.0:16025 app:app Restart=always RestartSec=10