1

I'm trying to send two parameters to a URL routed with Flask.

If I do:

curl -i http://127.0.0.1:5000/api/journeys/count?startStationName=Hansard%20Mews,%20Shepherds%20Bush&endStationName=Farringdon%20Lane,%20Clerkenwell

Then my code which is:

@application.route('/api/journeys/count', methods=['GET'])
def journeys():
    print request.args
    startStationName = request.args.get('startStationName')
    endStationName = request.args.get('endStationName')

Should print a dict with startStationName and endStationName defined.

However, instead, only the first parameter seems to be received:

ImmutableMultiDict([('startStationName', u'Hansard Mews, Shepherds Bush')])

Anybody got any idea what I'm doing wrong? I have a feeling there must be some kind of stupid mistake or misunderstanding somewhere but I've been looking for an hour and can't find it.

1
  • You missed the [1] <process number> and [1]+ Exit <exit code> outputs on the shell.. Commented Nov 29, 2014 at 15:51

1 Answer 1

1

Your shell interprets the & as a put the command in the background character. To prevent this, quote the whole URL:

curl -i "http://127.0.0.1:5000/api/journeys/count?startStationName=Hansard%20Mews,%20Shepherds%20Bush&endStationName=Farringdon%20Lane,%20Clerkenwell"
Sign up to request clarification or add additional context in comments.

1 Comment

Ah brilliant, it works now. Thanks. Glad I asked now otherwise I would have been scratching my head for a long time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.