I need to hit the fastapi with multiple images
@app.post("/text")
def get_text(files: List[UploadFile] = File(...)):
its working when I try uploading multiple images using /docs interface, I tried with one file its working fine here is the code for it
import requests
import json
def get_text(image_path):
#images={}
url = 'http://address/text'
try:
with open(image_path, "rb") as im:
image_data={"files":im}
response=requests.post(url,files=image_data)
return json.loads(response.text)
except Exception as er:
print("error occured")
return "{} error occured".format(er)
when I tried adding more images to the image_data but i am getting error.
image_data ={"files":[]}
for image in image_list:
with open(image, "rb") as im:
image_data['files'].append(im)
tried above code but no use.
error message after running the above error message