title: Fast API - how to show an image from POST in GET?
body: <p>I'm creating an app using FastAPI that is supposed to generate resized version of uploaded images. The upload should be done through POST/images and after calling a path /images/800x400 it should show a random image from the database with 800x400 size.
  I'm getting an error while trying to display an image.</p>
  <pre><code> from fastapi.responses import FileResponse
   import uuid
  
   app = FastAPI()
  
   db = []
  
  @app.post(&quot;/images/&quot;)
  async def create_upload_file(file: UploadFile = File(...)):
  
      contents = await file.read() 
  
      db.append(file)
  
      with open(file.filename, &quot;wb&quot;) as f:
          f.write(contents)
  
      return {&quot;filename&quot;: file.filename}
  
  @app.get(&quot;/images/&quot;)
  async def show_image():  
       return db[0]
  </code></pre>
  <p>As a response I get:</p>
  <pre><code>{
    &quot;filename&quot;: &quot;70188bdc-923c-4bd3-be15-8e71966cab31.jpg&quot;,
    &quot;content_type&quot;: &quot;image/jpeg&quot;,
    &quot;file&quot;: {}
  }
  </code></pre>
  <p>I would like to use: return FileResponse(some_file_path)
  and in the file path put the filename from above. Is it right way of thinking?</p>