title: How to serve file with flask and then download it with curl
body: <p>So I am trying to make an API with flask and then use it with javascript to display some images on the browser but I am running into problems with unit-testing whether the image sending (through Flask) works properly.  This is the flask code I have right now</p>
  
  <pre><code>@api.route("/pictures/&lt;picture_name&gt;")
  def send_picture(picture_name):
      """Used to send the requested picture from the pictures folder."""
      return api.send_static_file(picture_name)
  </code></pre>
  
  <p>And then I am trying to download say for example an image <code>puppy.png</code> with the following command </p>
  
  <pre><code>curl -O --request GET "http://localhost:8000/pictures/tank.png"
  </code></pre>
  
  <p>I can open the same link on my browser and see the file perfectly so I know the <code>send_static_file</code> function is working properly.  But the <code>curl</code> command above downloads the file in such a way that it can't be opened.  Is there something else I am doing wrong here?</p>
  
  <p>I am not that familiar with Python and Flask yet...</p>
  
  <p>EDIT : Somehow the same thing works perfectly fine with <code>wget</code> so I am wondering if this is a problem with the way I am making the curl call.  Is there something I am doing wrong?  Could someone explain how exactly something is downloaded via HTTP?  As in are there any special headers to the get request?  If not then what is the response formatted like and how is the file stored?</p>