flask-restful how to fetch GET parameter
flask, flask-restful
Solution
You can use the `RequestParser` bundled along with Flask-Restful.
from flask_restful import reqparse
class YourAPI(restful.Resource):
def get(self):
parser = reqparse.RequestParser()
parser.add_argument('city')
args = parser.parse_args()
city_value = args.get('city')
By default, the request parser searches json, form fields and query string (as it is in your case) for the key named `city`. The variable `city_value` will have the value passed in the API request.
Problem
i'm wondering how to fetch `GET` parameters in flask-restful like his `/hi/city?=NY` i can do like this `/hi/city/NY` using `/hi/city/<string:ccc>` but how to do so with `/hi/city?=NY` . i checked the documentation and it seems like using `reqparse` : http://flask-restful.readthedocs.org/en/latest/reqparse.html but still couldn't figure out how