| from typing import Any | |
| import pytesseract | |
| import urllib.request | |
| from PIL import Image | |
| pytesseract.pytesseract.tesseract_cmd = r'E:\tesseract ocr\tesseract.exe' | |
| class EndpointHandler(): | |
| def __init__(self): | |
| pass | |
| def __call__(self, imageUrl: str) -> str: | |
| urllib.request.urlretrieve(imageUrl, "image.jpg") | |
| img = Image.open("image.jpg") | |
| text = pytesseract.image_to_string(img) | |
| print(text) | |
| return text |