I am using the following code:
@api.route('/akilo/<a>/<b>/')
@api.route('/akilo/<c>/')
class Akilo(Resource):
def get(self, a, b, c):
if a and b:
return a + b
else:
return c
to get different responses from the same resource, depending on which parameters I am using
When I make a request with:
/select/akilo/bom/dia/
I get the following error:
TypeError: get() takes exactly 4 arguments (3 given)
Could you help me?
You either need to change the signature of get
to make a
, b
, and c
optional.
def get(a=None, b=None, c=None):
Or you need to provide default values for the unused ones in your routes.
@api.route('/akilo/<a>/<b>/', defaults={'c': None})
@api.route('/akilo/<c>/', defaults={'a': None, 'b': None}) t