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 trialTucker Fischer
10,517 PointsWorkspace 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.
2 Answers
Mark Ryan
Python Web Development Techdegree Graduate 28,648 PointsHi, 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!
Eric Peppler
3,675 PointsFor future reference, you must type this into the console or else nothing works:
python simple_app.py