thoth_app / test_ocr2.py
GitHub Actions
Sync from GitHub
4f54856
raw
history blame contribute delete
582 Bytes
import requests
from PIL import Image
import io
img = Image.new('RGB', (100, 30), color = (73, 109, 137))
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='PNG')
img_byte_arr = img_byte_arr.getvalue()
url = "https://ocr-service-410603182993.australia-southeast2.run.app/upload"
for field in ['image', 'upload', 'data', 'document']:
files = {field: ('test.png', img_byte_arr, 'image/png')}
r = requests.post(f"{url}?lang=cop", files=files)
print(f"Field: {field} -> Status: {r.status_code}")
if r.status_code == 200:
print(r.text)
break