</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/20001229/how-to-get-posted-json-in-flask" dir="ltr">How to get POSTed JSON in Flask?</a>
<span class="question-originals-answer-count">
(8 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2016-05-17 16:22:30Z" class="relativetime">3 years ago</span>.</div>
</div>
</aside>
I've got a google-maps lookup with autocomplete on the client side - I'm trying to transfer the "place" object over to the server once the user selects it - I could parse it down client-side, but I figured it's easier to do server-side. I verified from the browser 'network' inspect that it is sending over the correct json object, but server side I can't get the right object. I've tried every permutation of request.* that I can find and either get None or a <module 'flask.json'>
which I know isn't right.
Code:
function sendplace() {
$('placebutton').click(function() {
var add1 = place;
console.log(place);
$.ajax({
url: '/new_place2',
data: JSON.stringify(place),
contentType: 'application/json;charset=UTF-8',
type: 'POST',
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
and server-side:
@app.route('/new_place2', methods=['GET', 'POST'])
def new_place2():
place = request.form.get('place')
print "address: ", place
return ("Success, (*&)er!")
</div>