title: How to POST multiple images to FastAPI server using Python requests?
body: <p>I would like to send multiple images to FastAPI backend using Python requests.</p>
  <p><strong>Server side</strong></p>
  <pre><code>from fastapi import FastAPI, UploadFile, File
  from typing import List
  app = FastAPI()
  
  @app.post(&quot;/&quot;)
  def index(file: List[UploadFile] = File(...)):
      list_image = []
      for i in file:
          list_image.append(i.filename)
      return {&quot;list_image&quot;: list_image}
  </code></pre>
  <p><strong>Client side</strong></p>
  <p>Currently, I can only send a request with a single image. However, I would like to be able to send multiple images.</p>
  <pre><code>import requests
  import cv2
  
  frame = cv2.imread(&quot;../image/3.png&quot;)
  imencoded = cv2.imencode(&quot;.jpg&quot;, frame)[1]
  file = {'file': ('image.jpg', imencoded.tostring(),
                      'image/jpeg', {'Expires': '0'})}
  
  response = requests.post(&quot;http://127.0.0.1:8000/&quot;, files=file)
  </code></pre>