I want to pass an array as a list in python api,but its working as expected.here is the code below of my input section of python api
here a is a string and b is list parameter.
tfidf_get_args = reqparse.RequestParser()
tfidf_get_args.add_argument("a", type=str, help="Enter Landing page url:",required=True)
tfidf_get_args.add_argument("b", type=str,action='append', help="Enter a list urls,separated by a comma.Hit enter when you finished:",required=True)
class tfidf(Resource):
def post(self):
my_list=[]
try:
str_type = 'string format'
array_type = ['1','2']
c = request.values.get('a')
d = request.values.get('b')
if type(d) == type(str_type):
print("is String")
new_str = d.replace("[", "")
new_str = new_str.replace("]", "")
new_str = new_str.replace('"', "")
my_list = new_str.split(",")
print(my_list)
print(type(my_list))
print("======================================")
my_list.insert(0,c)
print(my_list)
print("======================================")
elif type(d) == type(array_type):
print("is List")
my_list=d
print(my_list)
print("======================================")
my_list.insert(0,c)
print(my_list)
print("======================================")
else:
hhh="Invalid type input"
return jsonify({"status": True,"Input":hhh})
except:
print("=====Error======")
return jsonify({"status": False,"Input":"Error"})
my main objective is that taking one url from a and taking multiple urls form b and make a list of both.
my angular input response
a "https://www.arkadium.com/free-online-games/"
b […]
0 "http://games.disney.in/"
1 "https://www.king.com/games"
2 "https://www.bgames.com/"
Response
{ status: true, Input: "Invalid type input" }
as you can see its getting into else part.
how to solve this issue??
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…