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 trialmartin Kattam
Courses Plus Student 14,718 PointsUpdate the response from hello() to say "Hello {name}", replacing {name} with the passed-in name.
Why is this code not passing challenge Challenge Task 2 of 3 from Flask Basics: from flask import Flask. I get a "Bummer! '/' without a name gave a non-200 response."
from flask import Flask
app = Flask(__name__)
@app.route('/<name>')
def hello(name="Treehouse"):
return 'Hello %s' % name
5 Answers
Hanley Chan
27,771 PointsHi,
Step 1 asks to add a new route to hello() instead of overwriting the default. It should work if you put the route back in.
@app.route('/')
Mike Siwik
Front End Web Development Techdegree Student 14,814 Pointsfrom flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def hello(name="Steve"):
return 'Hello {}'.format(name)
This is how it should look
MUZ141140 Dennis Pomerai
10,215 Pointsfrom flask import Flask from flask import request
app = Flask(name)
@app.route('/') def index('name'='treehouse'): name = request.args.get('name',name) return "Hello {}".format(name)
shawn Jones
6,044 PointsI'm stuck id did everything and no response from flask import Flask from flask import request app = Flask(name)
@app.route('/') @app.route('/<name>') def index(name="Shawn"): return "Hello {}".format(name)
Andreas cormack
Python Web Development Techdegree Graduate 33,011 Pointshi martin it asks you to add a default route.
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def hello(name="Treehouse"):
return 'Hello {}'.format(name)
martin Kattam
Courses Plus Student 14,718 PointsThanks.
martin Kattam
Courses Plus Student 14,718 Pointsmartin Kattam
Courses Plus Student 14,718 PointsThanks, makes sense now. And it worked.