This may be similar issue https://github.com/rethinkdb/rethinkdb/issues/3211.
On this line form the example:
inserted = r.table('todos').insert(request.json).run(g.rdb_conn)
I assume It requires JSON formatted data so your request.data should be verified if it is a JOSN formatted dictionary. Also the properties in the JSON formatted data should be utf8 encoded strings instead of unicode. I am not sure if the
curl http://localhost:5000/todos -d "data=Remember the milk" -X POST
generates JSON formatted body like {data:"Remember the milk"} to be send to the server, but I would suggest you to add additional logic there and verify if the data that comes from the client is not corrupted and follows the correct data schema. Something like:
@app.route("/todos", methods=['POST'])
def new_todo():
client_data = json.loads(request.data)
object_to_be_inserted = {
'property1': client_data['property1].encode('utf-8') if 'property1' in client_data else '',
'property2': client_data['property2].encode('utf-8') if 'property2' in client_data else ''
}
inserted = r.table('todos').insert(object_to_be_inserted).run(g.rdb_conn)
return jsonify(id=inserted['generated_keys'][0])