25 lines
651 B
Bash
25 lines
651 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
|
PORT="${OCR_PORT:-23567}"
|
|
TMP="/tmp/ocr-test-$$.jpg"
|
|
|
|
if [[ ! -d "${ROOT}/.venv" ]]; then
|
|
echo "请先 bash install.sh"
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1091
|
|
source "${ROOT}/.venv/bin/activate"
|
|
python3 -c "from PIL import Image; Image.new('RGB',(200,80),(255,255,255)).save('${TMP}')"
|
|
|
|
echo "==> GET /health"
|
|
curl -sS "http://127.0.0.1:${PORT}/health" || { echo "FAIL: OCR 未启动"; exit 1; }
|
|
echo ""
|
|
|
|
echo "==> POST /api/ocr/regions"
|
|
curl -sS -w "\nHTTP %{http_code}\n" -F "file=@${TMP};type=image/jpeg" \
|
|
"http://127.0.0.1:${PORT}/api/ocr/regions"
|
|
rm -f "${TMP}"
|