Refactor server.py: add base64 support, separate from training
- POST /solve accepts JSON with base64 encoded image - POST /solve/upload keeps multipart file upload compatibility - Server only depends on inference code (onnxruntime), no torch - Catch invalid image errors with proper 400 response - Update CLAUDE.md with new API documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
16
CLAUDE.md
16
CLAUDE.md
@@ -440,11 +440,19 @@ uv run python cli.py serve --port 8080
|
||||
|
||||
## HTTP 服务 (server.py,可选)
|
||||
|
||||
纯推理服务,不依赖 torch / 训练代码,仅需 onnxruntime + FastAPI。
|
||||
|
||||
```python
|
||||
# FastAPI 服务,提供 REST API
|
||||
# POST /solve - 上传图片,返回识别结果
|
||||
# 请求: multipart/form-data,字段名 image
|
||||
# 响应: {"type": "normal", "result": "A3B8", "confidence": 0.95, "time_ms": 45}
|
||||
# POST /solve - JSON base64 图片识别
|
||||
# 请求: {"image": "<base64>", "type": "normal"} (type 可选)
|
||||
# 响应: {"type": "normal", "result": "A3B8", "raw": "A3B8", "time_ms": 12.3}
|
||||
#
|
||||
# POST /solve/upload - multipart 文件上传识别
|
||||
# 请求: multipart/form-data, 字段名 image, 可选 query param type
|
||||
# 响应: 同上
|
||||
#
|
||||
# GET /health - 健康检查
|
||||
# 响应: {"status": "ok", "models_loaded": true}
|
||||
```
|
||||
|
||||
## 关键约束和注意事项
|
||||
|
||||
Reference in New Issue
Block a user