webserver.py import flask from flask import Flask, jsonify,request import base64 import datetime import ocr.ocr server=flask.Flask(__name__) @server.route('/ocr',methods=['post','get']) def ocr_idcard(): params = request.json if request.met
webserver.py
import flaskfrom flask import Flask, jsonify,request
import base64
import datetime
import ocr.ocr
server=flask.Flask(__name__)
@server.route('/ocr',methods=['post','get'])
def ocr_idcard():
params = request.json if request.method == "POST" else request.args
print(params['img'])
#rs = ocr.ocr.ocr_idcard('/root/PY/ocr/ex.jpg')
rs = ocr.ocr.ocr_idcard(params['img'])
return jsonify({'result': rs})
@server.route('/js',methods=['post','get'])
def js():
params = request.json if request.method == "POST" else request.args
print(params['img'])
return jsonify({'result': request.json})
server.run(host="0.0.0.0",port=8808,debug=True)
启动脚本 restart.sh
kill -9 `cat pid`nohup python3 -u webserver.py & echo $! > pid