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 trialBrian Ross
11,209 PointsCan't seem to figure this one out. Bummer! didn't get the expected result
Not sure what I'm doing wrong, or what it's really even specifically asking me to do.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
@app.route('/<name>')
def index(name="brian"):
return 'Hello {}'.format(app)
Brian Ross
11,209 PointsSo then I tried this, and it seems like I'm getting closer?
from flask import Flask from flask import request app = Flask(name)
@app.route('/') @app.route('/<name>')
def index(name): return 'Hello {}'.format(name)
Brian Ross
11,209 PointsThen I tried this and I got an error that says : "Bummer! '/' gave a non-200 response. Did you change the route?" No, I didn't change the route. Am I supposed to? To where?
from flask import Flask from flask import request app = Flask(name)
@app.route('/') def index(): return 'Hello {}'.format(input())
Brian Ross
11,209 PointsThis is my last crack at it before I just take a break for a bit lol. Still can't get it. Not sure what it wants me to put in the app route. Am I missing something obvious?
from flask import Flask from flask import request app = Flask(name)
@app.route('/?index') def index(name="Brian"): name = request.args.get('name', name) return "Hello from {}".format(name)
1 Answer
Brian Ross
11,209 PointsFinally figured it out.
from flask import Flask from flask import request app = Flask(name)
@app.route('/') def index(): name = request.args.get('name') return 'Hello {}'.format(name)
Brian Ross
11,209 PointsBrian Ross
11,209 PointsSo then I tried this too and it doesn't work
from flask import Flask from flask import request app = Flask(name)
@app.route('/') @app.route('/<name>') def index(name="brian"): return 'Hello {}'.format(name)