title: Send form data to MongoDB using Flask
body: <p>I'm having troubles sending my <code>form</code> data to MongoDB with a Flask setup. The form looks something like this: <strong><a href="https://jsfiddle.net/8gqLtv7e" rel="nofollow">https://jsfiddle.net/8gqLtv7e</a></strong></p>
  
  <p>On the client-side, I see no errors. But when I submit the form, I receive a 500 Internal Server Error and I'm having a hard time finding the solution. The problem is the last line below in my <code>views.py</code> file:</p>
  
  <pre><code>@app.route('/recordReport', methods=['POST'])
  def recordReport():
      homeReportsCollection = db["reports"]
      address=request.form.get['address']
      rgbImage=request.form.get['rgb']
      homeReportsCollection.insert({'address':address, 'rgb':rgbImage})
  </code></pre>
  
  <p>Because if I replace that with <code>return json.dumps({'status':'OK', 'address':'address', 'rgb':'rgbImage'})</code>, I can see the correct data in my browser. Am just not able to send it to a collection in MongoDB.</p>