Skip to content

Commit 608e225

Browse files
committed
Doc update + minor improvement to /process method.
1 parent 336c12c commit 608e225

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ocr_service/api/api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def info() -> Response:
2929

3030
@api.route("/process", methods=["POST"])
3131
def process() -> Response:
32+
""" Processes raw binary input stream, file, or
33+
JSON containing the binary_data field in base64 format
34+
35+
Returns:
36+
Response: json with the result of the OCR processing
37+
"""
3238
stream = None
3339
file_name: str = ""
3440

@@ -53,6 +59,8 @@ def process() -> Response:
5359

5460
try:
5561
record = json.loads(stream)
62+
if isinstance(record, list) and len(record) > 0:
63+
record = record[0]
5664
if isinstance(record, dict) and "binary_data" in record.keys():
5765
stream = base64.b64decode(record["binary_data"])
5866

0 commit comments

Comments
 (0)