Text

OCR Connection with Django fails

I gave been trying to integrate the ocr soltution to my django project. Below are my codes snippet and the error it's returning

import requests

from django.conf import settings

import io



def extract_text_from_image(image_path):


    payload = {

        "data": image_path,  # Example data from the request

        "apiKey": settings.MYSCRIPT_API_KEY

    }


    with io.open(image_path, 'rb') as f:

        response = requests.post(

            'https://api.myscript.com/v1/endpoint', files={image_path: f}, data=payload)


    return response.content.decode()




   raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.myscript.com', port=443): Max retries exceeded with url: /v1/endpoint (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x00000243C9A651B0>: Failed to resolve 'api.myscript.com' ([Errno 11001] getaddrinfo failed)"))
[26/Apr/2025 18:42:05] "POST /app/bulk-upload-script/ HTTP/1.1" 500 229029



How do I resolve this? What am I doing wrong?
1 Comment

Hello,


Thank you for contacting us.

There are two problems in the code that you have shared with us:

  1.  MyScript performs exclusively handwriting recognition with digital ink as input
    So if you want to recognize the content of an image or a scanned file (OCR), we cannot help, for more details please look at  https://developer.myscript.com/docs/interactive-ink/4.0/concepts/digital-ink-vs-ocr/
  2. The endpoint that you are using is not the correct one: to use our Web REST APIs, you should use https://cloud.myscript.com/api/v4.0/iink/recognize or https://cloud.myscript.com/api/v4.0/iink/batch 

        For more details on the Web APIs use, please refer to https://developer.myscript.com/docs/interactive-ink/4.0/web/overview/introduction/


Best regards,


Gwenaëlle

Login or Signup to post a comment