Skip to content

Instantly share code, notes, and snippets.

@cokia
Created November 19, 2019 09:13

Revisions

  1. cokia created this gist Nov 19, 2019.
    32 changes: 32 additions & 0 deletions flask-simple-digits-ocr.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #-*- coding: utf-8 -*-
    from flask import Flask, request
    import os
    import base64
    import urllib.parse
    import json
    import subprocess

    app = Flask(__name__)


    @app.route("/captcha", methods=["GET"])
    def captcha1():
    base164 = request.args.get('image') #title
    data = urllib.parse.unquote(base164)
    #data = json.loads(base64)
    png_recovered = base64.b64decode(data)
    x = subprocess.check_output(['tesseract temp.png a.txt -c tessedit_char_whitelist=0123456789'])
    f = open("a.txt", "r")
    fi = f.read()
    f.close()
    print(fi)
    return str(fi)


    if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=False)