api
Browse files- handler.py +16 -0
- requirements.txt +0 -0
handler.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
import pytesseract
|
| 3 |
+
import urllib.request
|
| 4 |
+
from PIL import Image
|
| 5 |
+
pytesseract.pytesseract.tesseract_cmd = r'E:\tesseract ocr\tesseract.exe'
|
| 6 |
+
class EndpointHandler():
|
| 7 |
+
def __init__(self):
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
+
def __call__(self, imageUrl: str) -> str:
|
| 11 |
+
urllib.request.urlretrieve(imageUrl, "image.jpg")
|
| 12 |
+
img = Image.open("image.jpg")
|
| 13 |
+
text = pytesseract.image_to_string(img)
|
| 14 |
+
print(text)
|
| 15 |
+
|
| 16 |
+
return text
|
requirements.txt
ADDED
|
Binary file (110 Bytes). View file
|
|
|