Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask Basics Welcome to Flask Request args

Vanessza Koos
Vanessza Koos
555 Points

Hi, I got this error message: Bummer: '/' gave a non-200 response. Did you change the route? Anybody any idea?

Hi, I got this error message: Bummer: '/' gave a non-200 response. Did you change the route? Anybody any idea what is the problem?

flask_app.py
from flask import Flask
from flask import request

app = Flask(__name__)

@app.route('/')
def index(name):
     return "Hello {}".format(name)
Christian Beckett
Christian Beckett
11,121 Points

Hi Vanessza. It looks to me like you just looked over something wrong. look at it again Vanessza Koos :P

1 Answer

Christian Beckett
Christian Beckett
11,121 Points

Or in my opinion it should look something like this

from flask import Flask
from flask import request

app = Flask(__name__)


app.route('/')
def index(name='Christian'):
    name = request.args.get('name', name)
    return 'Hello {}!'.format(name)

Good luck on your python adventure. Hope this helps some :3 Vanessza Koos

Christian Beckett
Christian Beckett
11,121 Points

Your welcome sorry it took me a while to answer. I'm learning python frameworks myself so if you need help please just ping me i will help Vanessza Koos

Vanessza Koos
Vanessza Koos
555 Points

All right I'll thank you!

Thank you