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

Gavin Ralston
Gavin Ralston
28,770 Points

Error: '/' gave a non-200 response.

route in the decorator isn't changed, function name isn't changed, and this appears to fit the challenge terms.

Also having some strange behavior in workspaces, where the flask app was running but I wound up back at the command line and I can't launch it again -- it says the address is already in use. In case that's somehow related.

flask_app.py
from flask import Flask
from flask import request

app = Flask(__name__)

@app.route('/')
@app.route('/<name>')
def index(name="Bob"):
    return "Hello {}".format(name)

So if you remove the default for name in index() it responds with non-200 response. If it's set to any value for default, though, I get an unexpected response error.

Any help would be appreciated.

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yeah, this challenge is all about the query string.

Gavin Ralston
Gavin Ralston
28,770 Points

On a completely unrelated note, I'm pretty sure Tron was awesome, so you might want to update your introduction in the logging or pdb video in the Python course to reflect that, sir.

END OF LINE.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

TRON was awesome (actually loved both movies). He didn't "shrink down" in TRON, though, he was digitized. :D

Gavin Ralston
Gavin Ralston
28,770 Points

Oh yeah! MCP proved that conservation of information doesn't stop even when you're converted to pure energy. So way ahead of string theory.

If it was Inner Space, though, you're dead on.

Gavin Ralston
Gavin Ralston
28,770 Points

This task is asking us to import request, so I should have been using request.args.get, not pulling the arguments from the route wrapper.