1234567891011121314151617181920212223 |
- from flask import request, Response,Flask,json
- from gevent.pywsgi import WSGIServer
- from gevent import monkey
- from crnn import crnnOcr
- from PIL import Image
- import numpy as np
- monkey.patch_all()
- app = Flask(__name__)
- @app.route('/ocr', methods=['POST', 'GET'])
- def repeatss():
- if request.method == 'POST':
- res = crnnOcr(Image.open(request.json['path']).convert("L"))
- return json.dumps(res)
- if __name__ == '__main__':
- # app.run(port=5002)
- http_server = WSGIServer(('0.0.0.0', 10666), app)
- http_server.serve_forever()
|