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 trialfelixwin
14,939 Points'/' gave a none 200 response
why is it, that my code gave a "none 200 response", even if I copied Kenneth's code, except the server starting (app.run(...) ), what as far as I understand isn't necessary.
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route("/index")
def index(name = "Hodor"):
name = request.arg.get("name", name)
return "Hello {name}".format(name)
1 Answer
felixwin
14,939 PointsOk, first of all, thank you for your Answer!
I found my mistake: its a misunderstanding of the .format()-methode right after the return in quotes stands "Hello {name}".format(name) that is wrong. The right solution to that Problem is leaving the curlys empty: "Hello {}".format(name)
thanks for your Time =)
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsWow, I totally overlooked that. Sorry about that! I missed that because Python 3.6 (the current latest version, and the one that's been my daily driver for a few months now) and later have "f strings". Python will evaluate whatever expression you want inside those brackets, so your statement would be perfectly valid without the call to
format
. In fact, if you're using Python 3.6 on your machine (which you should be), you should try it out!:return f"Hello {name}" # This is the entire statement in 3.6