title: Building an API that returns a prompted file download to excel
body: <p>I am working for a company that is looking to automate reports with python, these reports are built using excel.</p>
  <p>I'm currently using an HTTP Azure Function to host the api, and the main function looks like this.</p>
  <pre><code>def main(req: func.HttpRequest) -&gt; func.HttpResponse:
      logging.info('Python HTTP trigger function processed a request.')
      response = req.get_json()
      statement = #sql statement using payload data from post request
      df = rpt.sql_table_to_df(statement)
      frame = df.to_csv()
      filebytes= bytes(frame, 'utf-8')
      headers = {
         &quot;Content-Disposition&quot;: &quot;attachment; filename='report.csv'&quot;
      }
      return func.HttpResponse(body=filebytes, status_code=200, headers=headers, 
      mimetype='application/octet-stream')
  </code></pre>
  <p>The data that is sent to the api is JSON.</p>
  <p>How can I think about returning an excel file from a post request?</p>