Skip to content Skip to sidebar Skip to footer

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:

- or -

  • Open the file in binary mode - change open(pjoin(curdir, 'a.file')) to open(pjoin(curdir, 'store.json'), 'rb') (note the additional rb parameter).

Post a Comment for "Keep Getting Exception In Python Webserver"