chore: 修改默认端口为16016

This commit is contained in:
2026-07-17 12:15:50 +08:00
parent df2981889e
commit 02212e9ef7
3 changed files with 20 additions and 20 deletions
+12 -12
View File
@@ -1,6 +1,6 @@
# 📡 数据可视化图表生成器 - API 文档
> 版本:v1.1.0 | 基础地址:`http://192.168.0.101:16023`
> 版本:v1.1.0 | 基础地址:`http://192.168.0.101:16016`
---
@@ -60,7 +60,7 @@ Content-Type: application/json
**基础柱状图:**
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "产品, Q1, Q2, Q3, Q4\n手机, 1200, 1800, 2100, 2500\n平板, 800, 950, 1100, 1300\n笔记本, 600, 750, 900, 1050",
@@ -71,7 +71,7 @@ curl -X POST http://192.168.0.101:16023/api/chart \
**深色主题折线图 + 数据标签:**
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "月份, 营收(万), 利润(万), 用户(千)\n1月, 500, 80, 50\n2月, 680, 120, 85\n3月, 820, 160, 130\n4月, 1050, 230, 200\n5月, 1380, 350, 320",
@@ -86,7 +86,7 @@ curl -X POST http://192.168.0.101:16023/api/chart \
**区域分割对比图:**
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "月份, 方案A, 方案B\n1月, 85, 78\n2月, 88, 82\n3月, 92, 88\n4月, 90, 95\n5月, 95, 98\n6月, 98, 102",
@@ -103,7 +103,7 @@ curl -X POST http://192.168.0.101:16023/api/chart \
**堆叠柱状图:**
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "季度, 线上, 线下, 批发\nQ1, 300, 200, 150\nQ2, 450, 280, 200\nQ3, 520, 350, 180\nQ4, 680, 400, 250",
@@ -116,7 +116,7 @@ curl -X POST http://192.168.0.101:16023/api/chart \
**高分辨率大图:**
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "产品, 2023, 2024, 2025\nA, 100, 200, 300\nB, 150, 250, 350",
@@ -146,7 +146,7 @@ curl -X POST http://192.168.0.101:16023/api/chart \
### curl 示例
```bash
curl "http://192.168.0.101:16023/api/chart?data=%E4%BA%A7%E5%93%81,Q1,Q2%0A%E6%89%8B%E6%9C%BA,100,200%0A%E5%B9%B3%E6%9D%BF,150,250&type=bar&title=%E6%B5%8B%E8%AF%95" -o chart.png
curl "http://192.168.0.101:16016/api/chart?data=%E4%BA%A7%E5%93%81,Q1,Q2%0A%E6%89%8B%E6%9C%BA,100,200%0A%E5%B9%B3%E6%9D%BF,150,250&type=bar&title=%E6%B5%8B%E8%AF%95" -o chart.png
```
---
@@ -156,7 +156,7 @@ curl "http://192.168.0.101:16023/api/chart?data=%E4%BA%A7%E5%93%81,Q1,Q2%0A%E6%8
健康检查。
```bash
curl http://192.168.0.101:16023/api/health
curl http://192.168.0.101:16016/api/health
```
返回:
@@ -207,7 +207,7 @@ C, 20, 30, 40
```python
import requests
resp = requests.post('http://192.168.0.101:16023/api/chart', json={
resp = requests.post('http://192.168.0.101:16016/api/chart', json={
"data": "月份, 营收, 利润\n1月, 500, 80\n2月, 680, 120\n3月, 820, 160",
"chartType": "line",
"title": "增长趋势",
@@ -229,7 +229,7 @@ print(f"图片大小: {len(resp.content)} bytes")
const fetch = require('node-fetch');
const fs = require('fs');
const resp = await fetch('http://192.168.0.101:16023/api/chart', {
const resp = await fetch('http://192.168.0.101:16016/api/chart', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -248,7 +248,7 @@ fs.writeFileSync('chart.png', buffer);
### JavaScript (浏览器 fetch)
```javascript
const resp = await fetch('http://192.168.0.101:16023/api/chart', {
const resp = await fetch('http://192.168.0.101:16016/api/chart', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -268,7 +268,7 @@ document.body.appendChild(img);
### Shell (保存到文件)
```bash
curl -X POST http://192.168.0.101:16023/api/chart \
curl -X POST http://192.168.0.101:16016/api/chart \
-H "Content-Type: application/json" \
-d '{"data":"A,B\n1,2\n3,4","chartType":"bar"}' \
-o chart.png
+5 -5
View File
@@ -44,7 +44,7 @@ npm start
node server.js
```
服务默认运行在 `16023` 端口,可通过环境变量修改:
服务默认运行在 `16016` 端口,可通过环境变量修改:
```bash
PORT=8080 node server.js
@@ -52,14 +52,14 @@ PORT=8080 node server.js
### Web UI
浏览器访问 `http://localhost:16023` 即可使用可视化界面。
浏览器访问 `http://localhost:16016` 即可使用可视化界面。
### API 调用
#### POST 方式(推荐)
```bash
curl -X POST http://localhost:16023/api/chart \
curl -X POST http://localhost:16016/api/chart \
-H "Content-Type: application/json" \
-d '{
"data": "产品, Q1, Q2, Q3, Q4\n手机, 1200, 1800, 2100, 2500\n平板, 800, 950, 1100, 1300",
@@ -74,7 +74,7 @@ curl -X POST http://localhost:16023/api/chart \
#### GET 方式
```bash
curl "http://localhost:16023/api/chart?data=产品,Q1,Q2\n手机,100,200\n平板,150,250&type=bar&title=测试" -o chart.png
curl "http://localhost:16016/api/chart?data=产品,Q1,Q2\n手机,100,200\n平板,150,250&type=bar&title=测试" -o chart.png
```
#### Python 调用示例
@@ -82,7 +82,7 @@ curl "http://localhost:16023/api/chart?data=产品,Q1,Q2\n手机,100,200\n平板
```python
import requests
resp = requests.post('http://localhost:16023/api/chart', json={
resp = requests.post('http://localhost:16016/api/chart', json={
"data": "月份, 营收, 利润\n1月, 500, 80\n2月, 680, 120\n3月, 820, 160",
"chartType": "line",
"title": "增长趋势",
+3 -3
View File
@@ -5,7 +5,7 @@ const echarts = require('echarts');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 16023;
const PORT = process.env.PORT || 16016;
// 中间件
app.use(cors());
@@ -438,7 +438,7 @@ app.get('/api/docs', (req, res) => {
},
returns: 'image/png',
example: {
request: `curl -X POST http://localhost:16023/api/chart \\
request: `curl -X POST http://localhost:16016/api/chart \\
-H "Content-Type: application/json" \\
-d '{
"data": "产品, Q1, Q2, Q3, Q4\\n手机, 1200, 1800, 2100, 2500\\n平板, 800, 950, 1100, 1300",
@@ -465,7 +465,7 @@ app.get('/api/docs', (req, res) => {
},
returns: 'image/png',
example: {
request: `curl "http://localhost:16023/api/chart?data=产品,Q1,Q2\\n手机,100,200\\n平板,150,250&type=bar&title=测试" -o chart.png`
request: `curl "http://localhost:16016/api/chart?data=产品,Q1,Q2\\n手机,100,200\\n平板,150,250&type=bar&title=测试" -o chart.png`
}
}
]