当前位置 : 主页 > 编程语言 > python >

Python web(flask)

来源:互联网 收集:自由互联 发布时间:2022-06-15
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 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.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





上一篇:opencv编译Python接口
下一篇:没有了
网友评论