Open utterances-bot opened 1 year ago
files = request.files.to_dict(flat=False) ## files is a list containing two images. for i, file in enumerate(files): file.save(f'image-{i}.jpg')
This way files
will look like {'image': [<FileStorage: 'test.jpg' (None)>, <FileStorage: 'test.jpg' (None)>]}
, so parsing it with loop won't return files from request.
Correct way to set files
is files = request.files.to_dict(flat=False)['image']
.
r = requests.post(url, files=multiple_files, data=data)
Also data
is not set in code, so this row will rise an error.
Thank for this post! It really helps - simple and useful.
Build Web API with Flask -- Post and Receive Image - jdhao's digital space
In this post, I want to write about how to build a simple image processing web API that returns the size of an image. The topics include how to build this web API with Flask and how to post image to this web API and get response.
https://jdhao.github.io/2020/04/12/build_webapi_with_flask_s2/