I have this line in my code:
print "Location: ", url_for('get_user', id=9, _external=True)
The function to that shoudl be this one:
@app.route('/api/users/<int:id>')
def get_user(id):
print "Hello: ", id
user = User.query.get(id)
if not user:
abort(400)
return jsonify({'username': user.firstname})
(The Hello was just for me to see if that function gets triggered - which it doesn`t)
Then the error is this:
File "C:\Python27\lib\site-packages\werkzeug\routing.py", line 1616, in build
raise BuildError(endpoint, values, method)
BuildError: ('get_user', {}, None)
Do you have any idea why is that?
Thanks for your help!!!
PS.: If it helps I was initially using the tutorial about building an API with Flask by Miguel Grinberg which worked in the first place but then I played around and that was it...
get_userin module, where you callprint? - Jimilianid=9(the second argument,values, is empty). - Martijn Pieters@app.route('/api/users/', defaults={'id': -1})for example, you can useurl_for()without specifying anidvalue. - Martijn Pieters