恢复端口为16025
This commit is contained in:
@@ -49,10 +49,10 @@ COPY . .
|
|||||||
# 创建临时目录
|
# 创建临时目录
|
||||||
RUN mkdir -p /tmp/web_captures
|
RUN mkdir -p /tmp/web_captures
|
||||||
|
|
||||||
EXPOSE 16026
|
EXPOSE 16025
|
||||||
|
|
||||||
# 健康检查
|
# 健康检查
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
CMD curl -f http://localhost:16026/health || exit 1
|
CMD curl -f http://localhost:16025/health || exit 1
|
||||||
|
|
||||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16026", "--timeout", "120", "app:app"]
|
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "--timeout", "120", "app:app"]
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
- **当前版本**: v1.0.2
|
- **当前版本**: v1.0.2
|
||||||
- **提交历史**:
|
- **提交历史**:
|
||||||
- v1.0.0: 初始化项目
|
- v1.0.0: 初始化项目
|
||||||
- v1.0.1: 修改端口为 16026
|
- v1.0.1: 修改端口为 16025
|
||||||
- v1.0.2: 修复 agent-browser socket 权限问题
|
- v1.0.2: 修复 agent-browser socket 权限问题
|
||||||
|
|
||||||
## 操作步骤
|
## 操作步骤
|
||||||
@@ -39,5 +39,5 @@ git push -u origin master --tags
|
|||||||
|
|
||||||
## 服务地址
|
## 服务地址
|
||||||
|
|
||||||
- Web 界面: http://192.168.0.101:16026
|
- Web 界面: http://192.168.0.101:16025
|
||||||
- API 接口: http://192.168.0.101:16026/api/capture
|
- API 接口: http://192.168.0.101:16025/api/capture
|
||||||
22
README.md
22
README.md
@@ -104,18 +104,18 @@ API 信息接口
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 基础截图
|
# 基础截图
|
||||||
curl -X POST http://localhost:16026/api/capture \
|
curl -X POST http://localhost:16025/api/capture \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"url": "https://example.com", "action": "screenshot"}' \
|
-d '{"url": "https://example.com", "action": "screenshot"}' \
|
||||||
--output screenshot.png
|
--output screenshot.png
|
||||||
|
|
||||||
# 提取HTML
|
# 提取HTML
|
||||||
curl -X POST http://localhost:16026/api/capture \
|
curl -X POST http://localhost:16025/api/capture \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"url": "https://example.com", "action": "html"}'
|
-d '{"url": "https://example.com", "action": "html"}'
|
||||||
|
|
||||||
# 滚动加载后全页截图
|
# 滚动加载后全页截图
|
||||||
curl -X POST http://localhost:16026/api/capture \
|
curl -X POST http://localhost:16025/api/capture \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"url": "https://news.ycombinator.com",
|
"url": "https://news.ycombinator.com",
|
||||||
@@ -127,7 +127,7 @@ curl -X POST http://localhost:16026/api/capture \
|
|||||||
--output full_page.png
|
--output full_page.png
|
||||||
|
|
||||||
# 自定义视口
|
# 自定义视口
|
||||||
curl -X POST http://localhost:16026/api/capture \
|
curl -X POST http://localhost:16025/api/capture \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
@@ -144,7 +144,7 @@ import requests
|
|||||||
|
|
||||||
# 截图
|
# 截图
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
'http://localhost:16026/api/capture',
|
'http://localhost:16025/api/capture',
|
||||||
json={
|
json={
|
||||||
'url': 'https://example.com',
|
'url': 'https://example.com',
|
||||||
'action': 'screenshot'
|
'action': 'screenshot'
|
||||||
@@ -155,7 +155,7 @@ with open('screenshot.png', 'wb') as f:
|
|||||||
|
|
||||||
# 提取HTML
|
# 提取HTML
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
'http://localhost:16026/api/capture',
|
'http://localhost:16025/api/capture',
|
||||||
json={
|
json={
|
||||||
'url': 'https://example.com',
|
'url': 'https://example.com',
|
||||||
'action': 'html'
|
'action': 'html'
|
||||||
@@ -169,7 +169,7 @@ print(html)
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// 截图
|
// 截图
|
||||||
const response = await fetch('http://localhost:16026/api/capture', {
|
const response = await fetch('http://localhost:16025/api/capture', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -182,7 +182,7 @@ const response = await fetch('http://localhost:16026/api/capture', {
|
|||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
// 提取HTML
|
// 提取HTML
|
||||||
const response = await fetch('http://localhost:16026/api/capture', {
|
const response = await fetch('http://localhost:16025/api/capture', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -199,7 +199,7 @@ console.log(data.html);
|
|||||||
### 使用 Gunicorn
|
### 使用 Gunicorn
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gunicorn -w 4 -b 0.0.0.0:16026 app:app
|
gunicorn -w 4 -b 0.0.0.0:16025 app:app
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 Systemd 服务
|
### 使用 Systemd 服务
|
||||||
@@ -230,12 +230,12 @@ RUN playwright install chromium --with-deps
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16026", "app:app"]
|
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:16025", "app:app"]
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t web-capture-api .
|
docker build -t web-capture-api .
|
||||||
docker run -p 16026:16026 web-capture-api
|
docker run -p 16025:16025 web-capture-api
|
||||||
```
|
```
|
||||||
|
|
||||||
## 性能优化
|
## 性能优化
|
||||||
|
|||||||
4
app.py
4
app.py
@@ -583,5 +583,5 @@ if __name__ == '__main__':
|
|||||||
print(" agent-browser: npm install -g agent-browser && agent-browser install")
|
print(" agent-browser: npm install -g agent-browser && agent-browser install")
|
||||||
print(" playwright: pip install playwright && playwright install chromium")
|
print(" playwright: pip install playwright && playwright install chromium")
|
||||||
|
|
||||||
print("\n🚀 Server running on http://0.0.0.0:16026")
|
print("\n🚀 Server running on http://0.0.0.0:16025")
|
||||||
app.run(host='0.0.0.0', port=16026, debug=True)
|
app.run(host='0.0.0.0', port=16025, debug=True)
|
||||||
@@ -23,4 +23,4 @@ echo "运行方式:"
|
|||||||
echo " 开发模式: python3.12 app.py"
|
echo " 开发模式: python3.12 app.py"
|
||||||
echo " 生产模式: gunicorn -w 4 -b 0.0.0.0:5000 app:app"
|
echo " 生产模式: gunicorn -w 4 -b 0.0.0.0:5000 app:app"
|
||||||
echo ""
|
echo ""
|
||||||
echo "访问地址: http://localhost:16026"
|
echo "访问地址: http://localhost:16025"
|
||||||
@@ -6,14 +6,14 @@ services:
|
|||||||
image: web-capture-api:latest
|
image: web-capture-api:latest
|
||||||
container_name: web-capture-api
|
container_name: web-capture-api
|
||||||
ports:
|
ports:
|
||||||
- "16026:16026"
|
- "16025:16025"
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
- ./captures:/tmp/web_captures
|
- ./captures:/tmp/web_captures
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:16026/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:16025/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ echo " cd $(pwd)"
|
|||||||
echo " $PYTHON app.py"
|
echo " $PYTHON app.py"
|
||||||
echo ""
|
echo ""
|
||||||
echo "📖 访问地址:"
|
echo "📖 访问地址:"
|
||||||
echo " http://localhost:16026"
|
echo " http://localhost:16025"
|
||||||
echo ""
|
echo ""
|
||||||
echo "📚 API 文档:"
|
echo "📚 API 文档:"
|
||||||
echo " http://localhost:16026/api"
|
echo " http://localhost:16025/api"
|
||||||
@@ -7,7 +7,7 @@ import requests
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
API_URL = "http://localhost:16026"
|
API_URL = "http://localhost:16025"
|
||||||
|
|
||||||
|
|
||||||
def test_health():
|
def test_health():
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=openclaw
|
User=openclaw
|
||||||
WorkingDirectory=/home/openclaw/.openclaw/workspace-hz4th_coder/works/web-capture-api
|
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:16026 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
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user