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 trialShannon Healy
599 PointsAdd a view function named index. Give this view a route of "/". Make the view return your name. Help ? Anyone?
Can anybody tell me where Im going wrong with my code ? Im so confused!
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
4 Answers
Miguel de Luis Espinosa
41,279 Pointsyou only need to write a function just like the hello_world but returning your name.
The view is the function you write right after the @app.route('/') decorator
abdulkadir yıldız
2,711 Pointsfrom flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return __name__
Shannon Healy
599 Pointsok thanks i got it!!! your a star! was looking at it wrong for ages!
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Shannon
the problem is you have named your view 'hello_world' rather than index. Also return your name and not hello world, ohh one more thing you don't need the app.run()
Shannon Healy
599 PointsThank you Andreas!!!
Shannon Healy
599 PointsShannon Healy
599 Pointsok thank you!!!! However when do that I get an error "Bummer/ non 200 response" so I thought I had to add something extra ... like a kwargs function or something?