I\'ve a handler for a URL,
@app.route(\"/\", methods=[\'POST\'])
@crossdomain(origin=\'*\')
def hello():
ss=str(request.data)
print ss
return ss
I have been working with similar functionality and after a bit of messing around with the ajax and python, this is what I came up with for python reading the ajax data
JavaScript:
var data = {
data: JSON.stringify({
"value":'asdf'
})
}
};
$.ajax({
url:"/",
type: 'POST',
data: data,
success: function(msg){
alert(msg);
}
})
Python:
from flask import json
@app.route("/", methods=['POST'])
def get_data():
data = json.loads(request.form.get('data'))
ss = data['value']
return str(ss)