Search code examples
pythonimageapiurlweb-applications

How can I convert a local image to a URL for accessing external APIs?


I am building a Web app and I need to access an external API which only accepts an URL to my image in order to process it. These images will be taken from the app, therefore I am looking for a way to generate a URL based on them.

Is there any way to do that directly from python, generating the link?

Edit: The web app will only be local for now, so these images are only local, on my computer.


Solution

  • The external API will not be able to access your local images even if you host them using a local webserver. Instead, you can upload the images to storage services like AWS S3 or Azure Blob storage, and then provide those image URLs to the external API. This would be the simplest to do if your images aren't many in number.

    If there are lot of images, then instead of uploading each one of them, you may want to run a local webserver[ e.g nodejs, etc] and then use ngrok tunnels so that you can get a public URL that you can give to external API.