Python Flask Basics Character Builder Set a Cookie

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

Thank you, and the challenges are super picky sometimes.