229 lines
5.9 KiB
HTML
229 lines
5.9 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
<html lang="zh-CN">
|
|||
|
|
<head>
|
|||
|
|
<meta charset="UTF-8">
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|||
|
|
<title>OCR 服务接口文档</title>
|
|||
|
|
<style>
|
|||
|
|
:root {
|
|||
|
|
--primary-color: #2c3e50;
|
|||
|
|
--accent-color: #3498db;
|
|||
|
|
--bg-color: #f8f9fa;
|
|||
|
|
--border-color: #e9ecef;
|
|||
|
|
--code-bg: #f1f3f5;
|
|||
|
|
}
|
|||
|
|
body {
|
|||
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|||
|
|
line-height: 1.6;
|
|||
|
|
color: #333;
|
|||
|
|
max-width: 1000px;
|
|||
|
|
margin: 0 auto;
|
|||
|
|
padding: 20px;
|
|||
|
|
background-color: #fff;
|
|||
|
|
}
|
|||
|
|
h1, h2, h3 {
|
|||
|
|
color: var(--primary-color);
|
|||
|
|
border-bottom: 2px solid var(--border-color);
|
|||
|
|
padding-bottom: 10px;
|
|||
|
|
margin-top: 30px;
|
|||
|
|
}
|
|||
|
|
h1 { border-bottom: none; font-size: 2.5em; text-align: center; margin-bottom: 40px; }
|
|||
|
|
.endpoint {
|
|||
|
|
background: #fff;
|
|||
|
|
border: 1px solid var(--border-color);
|
|||
|
|
border-radius: 8px;
|
|||
|
|
margin-bottom: 30px;
|
|||
|
|
padding: 20px;
|
|||
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|||
|
|
}
|
|||
|
|
.method {
|
|||
|
|
display: inline-block;
|
|||
|
|
padding: 4px 8px;
|
|||
|
|
border-radius: 4px;
|
|||
|
|
color: #fff;
|
|||
|
|
font-weight: bold;
|
|||
|
|
font-size: 0.9em;
|
|||
|
|
margin-right: 10px;
|
|||
|
|
}
|
|||
|
|
.post { background-color: #2ecc71; }
|
|||
|
|
.url { font-family: monospace; font-size: 1.1em; color: var(--primary-color); }
|
|||
|
|
|
|||
|
|
table {
|
|||
|
|
width: 100%;
|
|||
|
|
border-collapse: collapse;
|
|||
|
|
margin: 15px 0;
|
|||
|
|
}
|
|||
|
|
th, td {
|
|||
|
|
border: 1px solid var(--border-color);
|
|||
|
|
padding: 10px;
|
|||
|
|
text-align: left;
|
|||
|
|
}
|
|||
|
|
th { background-color: var(--bg-color); font-weight: 600; }
|
|||
|
|
|
|||
|
|
code, pre {
|
|||
|
|
font-family: Consolas, Monaco, "Andale Mono", monospace;
|
|||
|
|
background-color: var(--code-bg);
|
|||
|
|
border-radius: 4px;
|
|||
|
|
}
|
|||
|
|
code { padding: 2px 4px; color: #e83e8c; }
|
|||
|
|
pre {
|
|||
|
|
padding: 15px;
|
|||
|
|
overflow-x: auto;
|
|||
|
|
border: 1px solid var(--border-color);
|
|||
|
|
}
|
|||
|
|
.note {
|
|||
|
|
background-color: #e3f2fd;
|
|||
|
|
border-left: 5px solid #2196f3;
|
|||
|
|
padding: 15px;
|
|||
|
|
margin: 20px 0;
|
|||
|
|
}
|
|||
|
|
.warning {
|
|||
|
|
background-color: #fff3cd;
|
|||
|
|
border-left: 5px solid #ffc107;
|
|||
|
|
padding: 15px;
|
|||
|
|
margin: 20px 0;
|
|||
|
|
}
|
|||
|
|
.url-box {
|
|||
|
|
display: inline-block;
|
|||
|
|
text-align: left;
|
|||
|
|
background: #f8f9fa;
|
|||
|
|
padding: 15px 20px;
|
|||
|
|
border: 1px solid #e9ecef;
|
|||
|
|
border-radius: 8px;
|
|||
|
|
margin: 10px 0;
|
|||
|
|
}
|
|||
|
|
.url-row {
|
|||
|
|
margin-bottom: 5px;
|
|||
|
|
}
|
|||
|
|
.url-row:last-child {
|
|||
|
|
margin-bottom: 0;
|
|||
|
|
}
|
|||
|
|
.url-label {
|
|||
|
|
font-weight: 600;
|
|||
|
|
color: #2c3e50;
|
|||
|
|
display: inline-block;
|
|||
|
|
width: 110px;
|
|||
|
|
}
|
|||
|
|
</style>
|
|||
|
|
</head>
|
|||
|
|
<body>
|
|||
|
|
|
|||
|
|
<h1>OCR 服务接口文档</h1>
|
|||
|
|
|
|||
|
|
<div style="text-align: center; margin-bottom: 40px;">
|
|||
|
|
<p><strong>版本:</strong> 1.1.1 (Update)</p>
|
|||
|
|
|
|||
|
|
<div class="url-box">
|
|||
|
|
<div class="url-row">
|
|||
|
|
<span class="url-label">外网 Base URL:</span>
|
|||
|
|
<code>https://qd.zhaopinzao8dian.com/ocr-api</code>
|
|||
|
|
</div>
|
|||
|
|
<div class="url-row">
|
|||
|
|
<span class="url-label">内网 Base URL:</span>
|
|||
|
|
<code>http://127.0.0.1:9001</code>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<p style="margin-top: 15px;"><strong>支持格式:</strong> 图片 (JPG/PNG), PDF, Excel (.xlsx / .xls), PPT (.pptx / .ppt)</p>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<section>
|
|||
|
|
<h2>通用响应结构</h2>
|
|||
|
|
<p>所有接口请求成功均返回如下 JSON 结构:</p>
|
|||
|
|
<pre>{
|
|||
|
|
"code": 200, // 业务状态码 (200成功, 500错误)
|
|||
|
|
"data": "识别出的文本内容...", // 具体的文本结果
|
|||
|
|
"cost_time_ms": 150.5, // 处理耗时 (毫秒)
|
|||
|
|
"msg": "" // 错误信息 (仅出错时存在)
|
|||
|
|
}</pre>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
<section class="endpoint">
|
|||
|
|
<h3>1. 文件上传识别</h3>
|
|||
|
|
<div>
|
|||
|
|
<span class="method post">POST</span>
|
|||
|
|
<span class="url">/ocr</span>
|
|||
|
|
</div>
|
|||
|
|
<p>通过 `multipart/form-data` 表单上传本地文件进行识别。</p>
|
|||
|
|
|
|||
|
|
<h4>请求参数 (Form-Data)</h4>
|
|||
|
|
<table>
|
|||
|
|
<thead>
|
|||
|
|
<tr>
|
|||
|
|
<th width="20%">参数名</th>
|
|||
|
|
<th width="15%">类型</th>
|
|||
|
|
<th width="15%">必填</th>
|
|||
|
|
<th>说明</th>
|
|||
|
|
</tr>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<tr>
|
|||
|
|
<td><code>file</code></td>
|
|||
|
|
<td>File</td>
|
|||
|
|
<td>是</td>
|
|||
|
|
<td>二进制文件流。<br>支持:图片, PDF, Excel(.xlsx/.xls), PPT(.pptx/.ppt)</td>
|
|||
|
|
</tr>
|
|||
|
|
</tbody>
|
|||
|
|
</table>
|
|||
|
|
|
|||
|
|
<h4>CURL 示例 (内网)</h4>
|
|||
|
|
<pre>curl -X POST -F "file=@/path/to/old_data.xls" http://127.0.0.1:9001/ocr</pre>
|
|||
|
|
|
|||
|
|
<h4>响应示例</h4>
|
|||
|
|
<pre>{
|
|||
|
|
"code": 200,
|
|||
|
|
"data": "--- Sheet: Sheet1 ---\n这里是Excel中的文本内容...",
|
|||
|
|
"cost_time_ms": 320.5
|
|||
|
|
}</pre>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
<section class="endpoint">
|
|||
|
|
<h3>2. URL 网络文件识别</h3>
|
|||
|
|
<div>
|
|||
|
|
<span class="method post">POST</span>
|
|||
|
|
<span class="url">/ocr/url</span>
|
|||
|
|
</div>
|
|||
|
|
<p>提交一个可访问的文件链接,服务自动下载并识别。</p>
|
|||
|
|
|
|||
|
|
<h4>请求头 (Headers)</h4>
|
|||
|
|
<ul>
|
|||
|
|
<li><code>Content-Type: application/json</code></li>
|
|||
|
|
</ul>
|
|||
|
|
|
|||
|
|
<h4>请求参数 (JSON Body)</h4>
|
|||
|
|
<table>
|
|||
|
|
<thead>
|
|||
|
|
<tr>
|
|||
|
|
<th width="20%">参数名</th>
|
|||
|
|
<th width="15%">类型</th>
|
|||
|
|
<th width="15%">必填</th>
|
|||
|
|
<th>说明</th>
|
|||
|
|
</tr>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<tr>
|
|||
|
|
<td><code>url</code></td>
|
|||
|
|
<td>String</td>
|
|||
|
|
<td>是</td>
|
|||
|
|
<td>完整的下载链接 (需以 http/https 开头)</td>
|
|||
|
|
</tr>
|
|||
|
|
</tbody>
|
|||
|
|
</table>
|
|||
|
|
|
|||
|
|
<h4>CURL 示例 (内网)</h4>
|
|||
|
|
<pre>curl -X POST -H "Content-Type: application/json" \
|
|||
|
|
-d '{"url": "https://example.com/legacy_slides.ppt"}' \
|
|||
|
|
http://127.0.0.1:9001/ocr/url</pre>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
<div class="note">
|
|||
|
|
|
|||
|
|
<div class="warning">
|
|||
|
|
<h3>⚠️ 注意事项</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li><strong>PDF 处理:</strong> PDF 会先转换为图片再进行 OCR,页数越多耗时越长,建议对大文件进行异步处理或分片上传。</li>
|
|||
|
|
<li><strong>超时限制:</strong> URL 下载接口默认超时时间为 15 秒,请确保下载链接稳定。</li>
|
|||
|
|
</ul>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
</body>
|
|||
|
|
</html>
|