I would like to use a URL with a 'from' and 'to' date where it is also possible to only provide one of the two arguments. Due to that I need to know via a keyword if only one argument is provided if it is the 'from' or 'to' date.
How can I set the URL such that I can check if either of the arguments are provided and use them as variable in the respective class?
These threads did not solve my problem: flask restful: passing parameters to GET request and How to pass a URL parameter using python, Flask, and the command line.
class price_history(Resource):
def get(self, from_, to):
if from_ and to:
return 'all data'
if from_ and not to:
return 'data beginning at date "from_"'
if not from_ and to:
return 'data going to date "to"'
if not from_ and not to:
return 'please provide at least one date'
api.add_resource(price_history, '/price_history/from=<from_>&to=<to>')