Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask Basics Character Builder Set a Cookie

Daniel Bowen
Daniel Bowen
7,224 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
7,224 Points

Thank you, and the challenges are super picky sometimes.