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 Basics Character Builder Set a Cookie

Daniel Bowen
Daniel Bowen
8,577 Points

Not clear what I'm doing wrong

treehouse is clearly set as the key, what am I doing wrong?

flask_app.py
from flask import Flask
from flask import make_response

app = Flask(__name__)


@app.route('/save')
def save():
    response = make_response(redirect(url_for('index')))
    nothing = ''
    response.set_cookie('treehouse', nothing)
    return response

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I believe there are two things going on here, and mostly it has to do with Treehouse challenges being picky about what happens here. Apparently, it really doesn't want an empty string. And it also doesn't like your redirect. So I modified your code slightly so that it gives the results that Treehouse is expecting. Take a look:

from flask import Flask
from flask import make_response

app = Flask(__name__)

@app.route('/save')
def save():
    response = make_response()
    nothing = 'nothing'
    response.set_cookie('treehouse', nothing)
    return response

Hope this helps! :sparkles:

Daniel Bowen
Daniel Bowen
8,577 Points

Thank you, and the challenges are super picky sometimes.