app.py 554 B

1234567891011121314151617181920212223
  1. from flask import request, Response,Flask,json
  2. from gevent.pywsgi import WSGIServer
  3. from gevent import monkey
  4. from crnn import crnnOcr
  5. from PIL import Image
  6. import numpy as np
  7. monkey.patch_all()
  8. app = Flask(__name__)
  9. @app.route('/ocr', methods=['POST', 'GET'])
  10. def repeatss():
  11. if request.method == 'POST':
  12. res = crnnOcr(Image.open(request.json['path']).convert("L"))
  13. return json.dumps(res)
  14. if __name__ == '__main__':
  15. # app.run(port=5002)
  16. http_server = WSGIServer(('0.0.0.0', 10666), app)
  17. http_server.serve_forever()