I'm using flask and cannot seem to get POST methods working without getting a 405 Method Not allowed error back to client. Here's my route/view:
@app.route('/test',methods=['POST','GET'])
def test():
if request.method=='POST':
return jsonify({'status':'POST'})
elif request.method=='GET':
return jsonify({'status':'GET'})
I'm using javascript $.ajax to send inbound ajax request and i see the request arriving on the flask side as it prints out:
127.0.01 -- [] "POST /test HTTP/1.1" 405 -
so the server responds with 405, always. When i change to GET method on client side i can get flow-through and response. However I'd like to use POST (and POST JSON in the body of the request, etc.).
Is there some global setting preventing POST from working? Or other gotcha?
Aucun commentaire:
Enregistrer un commentaire