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 trial

Python Flask with SQLAlchemy Basics Creating a Basic Website with Flask Create a Flask App

Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,712 Points

Why? I canโ€™t pass the challenge. I keep getting Bummer: You should have a dunder main at the end of your file.

A dunder main at the end of file?

app.py
# insert your code here
from flask import Flask


app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello Flask'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port='8000')

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Hey Noor Hafiza Binti Ibrahim, your code is functionally correct.

However, the very picky checker is looking for two blank lines between the function definition and the dunder name statement.

Post back if you need more help. Good luck!!!

Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,712 Points

Thank you for the tips ๐Ÿ˜Š, Chris Iโ€™ve fixed the two blank lines between the function definition and the dunder name statement, but, the challenge still didnโ€™t pass. Instead, i got a: Bummer: Make sure to place your route after your app variable. So, yup iโ€™m still stuck ๐Ÿฅบ

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

For Task 3 the checker wants 2 blank lines above the function as well.

Is it just me or is this really bad design? if nothing is wrong with the code and it wants x lines after line of code, it should say, right?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Perhaps. I believe the checker uses regex to check correctness. It would be quite a task to have a regex for every failing case. Sometimes the cases overlap and an error is caught be a more general regex. The first failing regex causes the failure so it might not have the specific info youโ€™re looking for. In the โ€œTest Resultsโ€ panel, it shows which regex failed. This is how I debug failing student code.