title: Python Flask: Send file and variable
body: <p>I have two servers where one is trying to get a file from the other.  I am using Flask get requests to send simple data back and forth (strings, lists, JSON objects, etc.).  </p>
  
  <p>I also know how to send just a file, but I need to send an error code with my data.</p>
  
  <p>I'm using something along the following lines:</p>
  
  <p><strong>Server 1:</strong></p>
  
  <pre><code>req = requests.post('https://www.otherserver.com/_download_file', data = {'filename':filename})
  </code></pre>
  
  <p><strong>Server 2:</strong></p>
  
  <pre><code>@app.route('/_download_file', methods = ['POST'])
  def download_file():
      filename = requests.form.get('filename')
  
      file_data = codecs.open(filename, 'rb').read()
      return file_data
  </code></pre>
  
  <p><strong>Server 1:</strong></p>
  
  <pre><code>with codecs.open('new_file.xyz', 'w') as f:
      f.write(req.content)
  </code></pre>
  
  <p>...all of which works fine.  However, I want to send an error code variable along with <code>file_data</code> so that Server 1 knows the status (and not the HTTP status, but an internal status code).</p>
  
  <p>Any help is appreciated.</p>