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 trialArnaldo Acosta
15,870 PointsTypeError: Expected bytes
So as soon as I submit a name for my bear I get an TypeError: Expected bytes. Any help would be much appreciated! The error log goes like this:
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump() shows all variables in the frame dump(obj) dumps all that's known about the object
File "C:\Users\arnal_000\Desktop\Python\Flask\FlaskFirstProject\lib\site-packages\werkzeug_compat.py", line 190, in to_bytes raise TypeError('Expected bytes')
1 Answer
David Stevens
Python Web Development Techdegree Student 1,270 PointsHey Arnaldo!
Check the save
method in app.py
. It may be that it contains response.set_cookie('character', data)
when it really should be response.set_cookie('character', json.dumps(data))
.
Hope this helps!