Как мне управлять URL-адресом API следующим образом:
http://localhost:7071/api?type=cat,dog,bird
Вместо
http://localhost:7071/api?type=cat&type=dog&type=bird
Мой текущий код:
def main( req : func.HttpRequest) -> func.HttpResponse:
logging.info('Blahblah')
feed_type = req.params.get('type')
if not type:
try:
req_body = req.get_json()
except ValueError:
pass
else:
type = req_body.get('type')
#Then, maybe iterate over as list?
if feed_type :
feed_type.split(',') # split to list #[cat,dog,bird]
if (feed_type is not None) & ('cat' in feed_type) & ('dog' not in feed_type) & ('bird' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('dog' in feed_type) & ('cat' not in feed_type) & ('bird' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('bird' in feed_type) & ('cat' not in feed_type) & ('dog' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('cat' in feed_type) & ('dog' in feed_type) & ('bird' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('cat' in feed_type) & ('bird' in feed_type) & ('dog' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('dog' in feed_type) & ('bird' in feed_type) & ('cat' not in feed_type):
return func.HttpResponse(result, mimetype='application/json')
elif (feed_type is not None) & ('cat' in feed_type) & ('dog' in feed_type) & ('bird' in feed_type):
return func.HttpResponse(result, mimetype='application/json')
Смотрите здесь I нужно сделать все возможные перестановки. Однако в этом случае он фиксируется между cat/dog/bird
. Есть ли эффективный способ справиться с этим в python?