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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Grant Kropf](https://secure.gravatar.com/avatar/7494e412cdc98e4bd29ef2f7e050aa7c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Grant Kropf
3,421 PointsFlask Challenge 1: 200 error?
I get an 200 (routing?) error when I enter this code for Flask Challenge 1. I don't see the problem..
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
def index(name):
return "Hello {}".format(name)
[MOD: added ```python formatting -cf]
2 Answers
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsSorry, my other answer was for a different challenge. This one uses the URL query string to pass arguments not the URL itself.
Task 1 of 1: Import 'request' from 'Flask'. Then update the index view to return "Hello {name}", replacing {name} with a name argument in the query string.
from flask import Flask
# Import 'request' from 'Flask'....
from flask import request
app = Flask(__name__)
@app.route("/")
def index(name="Treehouse"):
# with a name argument in the query string.
name = request.args.get('name', name)
# update the index view to return "Hello {name}"
return "Hello {}".format(name)
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsYou also need to add a route for the name. It's also a good idea to give the name parameter a default for cases when the route '/' is used without a name.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def index(name='Student'):
return "Hello {}".format(name)
![Grant Kropf](https://secure.gravatar.com/avatar/7494e412cdc98e4bd29ef2f7e050aa7c?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Grant Kropf
3,421 PointsThanks. I tried your code (this is for challenge task 1 of 1 in flask basics), and it is telling me it didn't get the expected response.
Here is my code: It should be identical to yours.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def index(name='Student'):
return "Hello {}".format(name)
![Grant Kropf](https://secure.gravatar.com/avatar/7494e412cdc98e4bd29ef2f7e050aa7c?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Grant Kropf
3,421 PointsI tried this and it didn't work, do you know why it's telling me it didn't get the expected response?
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsThis answer is for another challenge. Please ignore.