TypeError: sequence of byte string values expected, value of type str found - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: Tutorials (https://python-forum.io/forum-4.html) +---- Forum: Tutorial Requests and Submissions (https://python-forum.io/forum-21.html) +---- Thread: TypeError: sequence of byte string values expected, value of type str found (/thread-38362.html) |
TypeError: sequence of byte string values expected, value of type str found - witgrefe - Oct-03-2022 I am trying to get mod_wsgi up and running but when I try to open a test page with the following code I get the error saying that a byte string is expected def application(environ,start_response): status = '200 OK' html = '<html>\n' \ '<body>\n' \ '<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n' \ 'mod wsgi Test Page\n' \ '</div>\n' \ '</body>\n' \ '</html>\n' response_header = [('Content-type','text/html')] start_response(status,response_header) return [html] I have tried various ways to convert the string but none are successful.If I try b'mod wsgi Test Page\n' \ I get ^bytes('mod wsgi Test Page\n', encoding= 'utf-8') I get: ^ SyntaxError: invalid syntax[/error] If I use: def application(environ, start_response): status = '200 OK' output = b'This is my Website!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]this works fine. |