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 trialStacey Normington
5,861 Pointscode challenge cookies
Kinda struggling with this one anyone know where I'm going wrong?
from flask import Flask, make_response
app = Flask(__name__)
@app.route('/save')
def save():
response = make_response() response.set_cookie('name', 'treehouse')
return response.set_cookie
2 Answers
Indiya Gooch
12,075 PointsNote: Edited as correct answer below this original answer
Your answer is nearly correct! The make response() end bracket is just misplaced:
@app.route('/save')
def save():
response = make_response()
response.set_cookie('name', 'treehouse')
return response
Indiya Gooch
12,075 PointsMy apologies, the answer i gave was the one for the character builder which you'll progress onto soon enough. The answer you're looking for is as follows:
from flask import Flask
from flask.helpers import make_response
app = Flask(__name__)
@app.route('/save')
def save():
response = make_response()
response.set_cookie('treehouse','value')
return response
make_response belongs to flask.helpers, so ensure you import it first. You can then make the response with the make_response() method, set a cookie on it, and return it.
Stacey Normington
5,861 PointsStacey Normington
5,861 PointsIt's saying it didn't get a treehouse cookie the code i used was identical to yours is workspaces down?