python - An example of POST request in Flask API gives "Method Not Allowed" -


i'm using flask api , want use post requests.

i want example post requests return something, keep getting error message "method not allowed".

i want give parameter(e.g query_params = 'name1' ) search user , return json, don't know give parameter , don't understand why i'm getting message. here did simple route:

@mod_api.route('/show-user', methods=['post']) def show_user():     query_params = 'name1'     query = {query_params: 'myname' }     json_resp = mongo.db.coordinates.find(query)     return response(response=json_util.dumps(json_resp), status=200, mimetype='application/json') 

any please?

the reason not doing post request against route, accepts post requests. here simplified example mongodb details removed illustrate this.

from flask import flask  app = flask(__name__)  @app.route('/show-user', methods=('post',)) def show_user():     return "name info"  if __name__ == "__main__":     app.run(debug=true) 

now if post request works, if request raises error saw:

curl -h "content-type: application/json" -x post -d '{}' http://127.0.0.1:5000/show-user name info  curl -h "content-type: application/json" -x http://127.0.0.1:5000/show-user  <!doctype html public "-//w3c//dtd html 3.2 final//en"> <title>405 method not allowed</title> <h1>method not allowed</h1> <p>the method not allowed requested url.</p> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -