Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTom Drury
10,546 PointsI got the error message: '/' gave a non-200 response. did you change the route? is this a problem with the code?
I have not changed the route, so wondering why I receive this error message. Thanks.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
def index():
name = request.args.get('name', name)
return 'Hello {}'.format(name)
2 Answers
Ricky Catron
13,023 PointsI think the error is because you are passing a second argument to request.args.get(). I think it should just be:
name = request.args.get('name')
Goodluck! --Ricky
Mike Siwik
Front End Web Development Techdegree Student 14,814 Pointsfrom flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
def index(name="Treehouse"):
return "Hello {}".format(name)
This is 100% correct
Tom Drury
10,546 PointsTom Drury
10,546 Pointsperfect. thanks.
Chen Wang
7,371 PointsChen Wang
7,371 PointsSo why do we use
request.args.get('name', name)
in the class?
Ricky Catron
13,023 PointsRicky Catron
13,023 PointsI believe the second argument is a default which only kicks in if the request variable is empty. It would also need to be declared beforehand. AKA you can't pass in name as the second argument without name having a value EX name="Treehouse" somewhere before it is passed in.
Goodluck! --Ricky