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 Build a Social Network with Flask How to Win Friends Handling 404s

404 error

I think there is an issue with the Challenge Task 2 of 3, as it seems to want what is needed for Challenge Task 3 of 3, to continue, and then just click the check work to have it complete.

2 Answers

Hi Rune,

Unfortunately you probably didn't find Mr. Owildeberry's answer very helpful.

First a link to the challenge:


Here's what I added to the bottom of lunch.py to get past part 2 of 3 for the challenge:

Challenge Task 2 of 3

Add a new function named not_found that returns the string "404". Remember, error handlers need to accept a single argument, the error. Decorate this function with @app.errorhandler(404). Add , 404 after your response, too.

def not_found(error):
    return "404", 404  

This is not the same as what is need to pass part 3 of the challenge:

Challenge Task 3 of 3

Now make not_found render the "404.html" template. Add an <h1> to the template with the 404 error code in it. Add a message to the template, if you want.

def not_found(error):
    return render_template('404.html'), 404

..which comes directly from the 'app.py' file found in the 'S4V5' folder of the course's zip download.

(Note: this is the only challenge so far where looking at the course's zip file download has been helpful to me.)

Of course you'll have to take a look at the '404.html' file under ''S4V5/templates/' folder of the course's zip,

to find the two lines needed for the {% block content %} section of the templates/404.html tab of the challenge.

Something like:

{% block content %}

<p>Wow, sorry, that page doesn't exist.</p>

{% endblock %}

Just wait to you get to the Tacocat challenge, though. Then you'll really be challenged!

Did you update your web browser and try a different web browser? =D