Python Flask Basics Welcome to Flask Clean URL Arguments

Ishita .
Ishita .
4,290 Points

How does a route and its view interact?

What happens exactly after a route is visited? Why is "name" required by the index function as an argument if it is present in the URL already?

1 Answer

Ryan Carson
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Ryan Carson
Treehouse Staff
@app.route('/')
@app.route('/<name>')
def index(name="Treehouse"):
    return "Hello from {}".format(name)

The value of name in the URL is passed to the index function, which is why it's an argument. Simply adding arguments to the URL string doesn't cause the app to act.