from flask import Flask, request, render_template from flask_cors import CORS, cross_origin import base64 import pytesseract app = Flask(__name__) app.debug = True app.secret_key = 'my_secret_key' app.config['CORS_HEADERS'] = 'Content-Type' app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 @app.route("/", methods=['GET', 'POST']) @cross_origin() def index(): if request.method == "POST": name = request.form["name"] #print(name) custom_config = r'--psm 6' with open("imageToSave.png", "wb") as fh: fh.write(base64.b64decode(name,' /')) text=pytesseract.image_to_string("imageToSave.png", config=custom_config) return text if __name__ == "__main__": app.run(host='0.0.0.0', port=6001)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question