lundi 25 juin 2018

Fetch multiple images from the server using Django

I am trying to download multiple image files from the server. I am using Django for my backend. Question related to single image has already been answered and I tried the code and it works on single image. In my application, I want to download multiple images in a single HTTP connection.

        from PIL import Image

        img = Image.open('test.jpg')
        img2 = Image.open('test2.png')

        response = HttpResponse(content_type = 'image/jpeg')
        response2 = HttpResponse(content_type = 'image/png')

        img.save(response, 'JPEG')
        img2.save(response2, 'PNG')

        return response #SINGLE

How can I fetch both img and img2 at once. One way I was thinking is to zip both images and unzip it on client size but I dont think that is good solution. Is there a way to handle this?




Aucun commentaire:

Enregistrer un commentaire