Python Flask Basics Welcome to Flask Request Variables

Tucker Fischer
Tucker Fischer
8,629 Points

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,153 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!