python 2.7 - Question marks in Flask Urls for routing -
this question has answer here:
- how data received in flask request 8 answers
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
Post a Comment