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

Python Flask Basics Welcome to Flask Request args

Import 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

flask_app.py
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

  1. Your python syntax is off. There should be a blank line between the import statements and the app variable being declared.
  2. The curly brackets{} should be regular parenthesis() around the name.
  3. @app.route has the curly brackets when it should be parenthesis.
  4. Your def line is incorrect. You shouldn't have the name variable inside the quote marks and no curly brackets, again regular parenthesis.
  5. 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.
  6. 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)

Four issues:

  1. In your view's parameters, you've put the entire keyword=value in quotes. Only the value should be in quotes.

  2. You have over-indented the line name= request.arg.get... and also, it should be request.args.get...

  3. The instructions specifically tell you to write return "Hello {name}" ... you wrote return "Hello {}" so change it

  4. You're doing your string formatting incorrectly. It should look like this: "{key}".format(key=value)