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 Variables

Workspace unavailable?

from flask import Flask from flask import request

app = Flask(name)

@app.route('/') def index(name="Treehouse"): return "Hello from {}".format(name)

app.run(debug=True, port=8000, host='0.0.0.0')

When I try to preview this it says workspace is unavailable.

1 Answer

Mark Ryan
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Ryan
Python Web Development Techdegree Graduate 28,154 Points

Hi, Tucker!

Were you successful in running this script? When creating a Flask instance, Flask() will expect an import_name argument. Usually the special variable __name__ is passed in by convention. You've passed in name which is not defined at this point.

app = Flask(__name__)

It also looks like you're planning to use name as a request argument in your index function. Not sure if you've had a chance to complete your code here - if so double check your code inside of this function. You should be able to pass ?name=Tucker into the url and have Tucker display in the template. Check back if you're stuck!