I want to use Flask in such a way where I can simply pass use localhost/data/?user=[123,234,345] and it will return those values in the body.
This is what I've tried:
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
@app.route('/data', methods=['GET','POST'])
def data():
user = request.args.getList('user', type=int)
users = []
for u in user:
try:
users.append(redisfunction(u))
except:
continue
return users
What am I doing wrong?
request.args.getList
should berequest.args.getlist
, lowercase of l, or it will cause error code 500, the reason I'm not find nowlocalhost/data?user=123&user=234&user=345
here is my simpe code:
then
curl 'localhost:5000/data?user=123&user=234&user=345'
flask output:
[123, 234, 345]
127.0.0.1 - - [14/Dec/2016 09:23:48] "GET /data?user=123&user=234&user=345 HTTP/