Python Flask Basics Character Builder Starting the Builder

Arnaldo Acosta
Arnaldo Acosta
11,625 Points

TypeError: 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\", line 190, in to_bytes raise TypeError('Expected bytes')

1 Answer

David Stevens
David Stevens
Python Web Development Techdegree Student 1,270 Points

Hey Arnaldo!

Check the save method in 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!