File size: 637 Bytes
d3be220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import base64

from flask import Flask, jsonify, request
from config import Config
from ocr.ml_predict import Predict

app = Flask(__name__)


class Web:
    def run(self):
        app.run(**Config.WEB)


@app.route('/check', methods=['POST'], strict_slashes=False)
def check():
    img = request.form.get('img')
    try:
        img = base64.b64decode(img)
    except Exception as e:
        pass
    if not img:
        return jsonify({'msg': 'Wrong format. '})
    result = Predict.share().get_coordinate(img)
    return jsonify({
        'msg': 'success',
        'result': result
    })


if __name__ == '__main__':
    Web().run()