Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask only sees first parameter from multiple parameters sent with curl

Tags:

python

flask

I am using curl to make a request to a Flask route that expects multiple query params. However, the log shows only the first param in the url, and Flask doesn't see the second param. What is going wrong?

@app.route('/path', methods=['GET'])
def foo():
    print request.args.get('param2')
    req = request.args.items()
    print req
curl http://localhost:5000/path?param1=1&param2=2
127.0.0.1 - - [01/Jun/2015 21:35:10] "GET /path?param1=1 HTTP/1.1" 200 -
None
[('param1', u'1')]
like image 735
MakleBirt Avatar asked Jun 02 '15 02:06

MakleBirt


1 Answers

See Bidhan's comment here. I was using curl without putting my URL inside double quotes.

To quote:

If you're using curl then you need to pass the url inside of quotes. It should look like curl "localhost:5000/path?param1=1&param2=2" . In the shell, & is used for forking processes and doesn't behave like you would expect it to. – Bidhan A

like image 187
MakleBirt Avatar answered Oct 08 '22 12:10

MakleBirt