python 2.7 - Question marks in Flask Urls for routing -


this question has answer here:

so have route in flask follows:

@app.route("/menu-card/<google_place_id>", methods=['get'])  

on navigating http://127.0.0.1:5000/menu-card/chijaxxhiumurjsr5qoqvsqjcci, proper response.

however tried changing url pattern follows:

@app.route("/menu-card?id=<google_place_id>", methods=['get']) 

on navigating http://127.0.0.1:5000/menu-card?id=chijaxxhiumurjsr5qoqvsqjcci, 404 error.what doing wrong ?

the part after ? query string, can using request.args. route should

@app.route("/menu-card", methods=['get']) 

and can id using:

google_place_id = request.args.get('id', none) 

where none default value if id not included in url. you'll have check if it's not equal none make sure has been passed.

search the quickstart page request.args see example.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -