mirror of
https://github.com/sml2h3/ocr_api_server.git
synced 2025-05-04 06:00:45 +08:00
When requesting a JSON path, returns a response with Content-Type json/application
当请求JSON路径时,返回 Content-Type 为 json/application 的响应
This commit is contained in:
parent
7f37543ffb
commit
7f07a52ddf
@ -4,7 +4,7 @@ import base64
|
||||
import json
|
||||
|
||||
import ddddocr
|
||||
from flask import Flask, request
|
||||
from flask import Flask, request, Response
|
||||
|
||||
parser = argparse.ArgumentParser(description="使用ddddocr搭建的最简api服务")
|
||||
parser.add_argument("-p", "--port", type=int, default=9898)
|
||||
@ -80,9 +80,9 @@ def get_img(request, img_type='file', img_name='image'):
|
||||
def set_ret(result, ret_type='text'):
|
||||
if ret_type == 'json':
|
||||
if isinstance(result, Exception):
|
||||
return json.dumps({"status": 200, "result": "", "msg": str(result)})
|
||||
return Response(json.dumps({"status": 200, "result": "", "msg": str(result)}), mimetype='application/json')
|
||||
else:
|
||||
return json.dumps({"status": 200, "result": result, "msg": ""})
|
||||
return Response(json.dumps({"status": 200, "result": result, "msg": ""}), mimetype='application/json')
|
||||
# return json.dumps({"succ": isinstance(result, str), "result": str(result)})
|
||||
else:
|
||||
if isinstance(result, Exception):
|
||||
|
Loading…
Reference in New Issue
Block a user