25 lines
655 B
Python
25 lines
655 B
Python
from flask import Flask, request, jsonify
|
|
import pytesseract
|
|
from PIL import Image
|
|
import io
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/extract-text', methods=['POST'])
|
|
def extract_text():
|
|
if 'image' not in request.files:
|
|
return jsonify({'error': 'No image file provided'}), 400
|
|
|
|
file = request.files['document']
|
|
file = request.files['image']
|
|
text = extract_text_from_image(file)
|
|
image = Image.open(io.BytesIO(file.read()))
|
|
|
|
# Replace with your Doctor OCR model if needed
|
|
text = pytesseract.image_to_string(image)
|
|
|
|
return jsonify({'text': text})
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=6001)
|