title: How can I send a json data along with a file in a curl request to handle by Flask?
body: <p>Problem:</p>
  
  <p>I want to send a file with <code>-F</code> option and along with a json data with <code>-d</code> to the flask route.But only either i can implement.</p>
  
  <p>Code I tried.</p>
  
  <blockquote>
    <p>curl -X POST -H "Content-Type: application/json" -d '{"username":"xyz","password":"xyz"}' <a href="http://192.168.150.113/test" rel="nofollow noreferrer">http://192.168.150.113/test</a></p>
  </blockquote>
  
  <p>Flask Code:</p>
  
  <pre><code>@app.route('/test',methods = ['GET', 'POST'])
  def test():
  if request.method == 'POST':
      data = request.data
  data = json.loads(data)
  return 'success'
  </code></pre>
  
  <p>With only File :</p>
  
  <pre><code>curl -X POST -F file=@sample.txt http://192.168.150.113/test
  @app.route('/process' , methods = ['GET', 'POST'])
  def process():
  if request.method == 'POST':
      f = request.files['file']
  if f:
      try:
  filename = secure_filename(f.filename)
  f.save( os.path.join(app.config['UPLOAD_FOLDER'], filename ))
  return 'success'
  </code></pre>
  
  <p>But without sending seperate request I want to combine these two POST request and handle using flask..</p>
  
  <p>Is there any way I can do this?</p>