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 trialManuel Montalvo
1,796 PointsImport request from Flask. Then update the index view to return "Hello {name}", replacing {name} with a name argument in
not sure were is the poblem
from flask import Flask
from flask import request
app = Flask{__name__}
@app.route{'/'}
def index{'name=Hello manuel'}:
name= request.arg.get{'name',name}
return 'Hello {}'.format {name}
2 Answers
Bryan Park
13,481 Points- Your python syntax is off. There should be a blank line between the import statements and the app variable being declared.
- The curly brackets{} should be regular parenthesis() around the name.
- @app.route has the curly brackets when it should be parenthesis.
- Your def line is incorrect. You shouldn't have the name variable inside the quote marks and no curly brackets, again regular parenthesis.
- The next line is over-indented, name and return below it should be lining up, and it should be args not arg. And again, correct the curly brackets to parenthesis.
- And parenthesis after the format on the return line.
It should look something like,
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
def index(name='manuel'):
name = request.args.get('name', name)
return 'Hello {}!'.format(name)
Nate Sturgeon
2,255 PointsFour issues:
In your view's parameters, you've put the entire keyword=value in quotes. Only the value should be in quotes.
You have over-indented the line name= request.arg.get... and also, it should be request.args.get...
The instructions specifically tell you to write return "Hello {name}" ... you wrote return "Hello {}" so change it
You're doing your string formatting incorrectly. It should look like this: "{key}".format(key=value)