Keep Getting Exception In Python Webserver
I have a pretty simple python webserver that returns a few web pages, and it keeps throwing TypeError: 'str' does not support the buffer interface. Here is my code, can anyone tell
Solution 1:
Sockets send and receive bytes, but you are attempting to send over unicode strings since you opened the file without specifying the mode (remember, in Python 3 all strings are unicode by default).
You can either:
- Use the
bytes
built-in function to transform the data
- or -
- Open the file in binary mode - change
open(pjoin(curdir, 'a.file'))
toopen(pjoin(curdir, 'store.json'), 'rb')
(note the additionalrb
parameter).
Post a Comment for "Keep Getting Exception In Python Webserver"