I am trying to send some data to a Flask app using json. When I send it I get a GET error in the console
GET http://super.secret.url/csv?callback=jQuery...
Javascript:
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: "http://super.secret.url/csv?callback=?",
data: JSON.stringify({message: id, condition: "new"}),
dataType: "json"
});
Flask (python):
@app.route('/csv', methods=['POST'])
@crossdomain(origin='*')
def edit_csv(path):
ip = request.remote_addr
sessionId = request.json['message']
type = request.json['condition']
csvFile = csv.reader(open('ip_log.csv'))
csvLines = [l for l in csvFile]
if(type == "new"):
for i in range(0, len(csvLines)):
if(csvLines[i][0] == ip):
csvLines[i][1] == sessionId
break
csvwriter = csv.writer(open('ip_log.csv', 'w'))
csvwriter.writerows(csvLines)
return ""
Edit
I am getting a 405. I know this is a cross domain request but I do have the server setup to handle that. I have a different function in the python file that works cross domain.