jeudi 24 mai 2018

Send and receive images using Flask

Currently I support sending 1 image per request like so:

img_b64 = fileToB64(img)

return {
    'base64': [{
        'name': 'img',
        'contentType': 'image/png'
    }],
    'img': img_b64
}

But I need to implement new feature than enables to send any number of images (usually 1 but max 4 images) per request. Is there an easy way to send list of images? Sth like this:

img_b64s = [fileToB64(img) for img in images]
return {
    'base64': [{
        'name': 'img',
        'contentType': 'image/png'
    }],
    'imgs': img_b64s
}




Aucun commentaire:

Enregistrer un commentaire