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
If I try b'mod wsgi Test Page\n' \ I get
I get:
SyntaxError: invalid syntax[/error]
If I use:
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]
Error:[wsgi:error] [pid 1062] [client 127.0.0.1:47306] TypeError: sequence of byte string values expected, value of type str found
I have tried various ways to convert the string but none are successful.If I try b'mod wsgi Test Page\n' \ I get
Error:html = '<html>\\n' \\ SyntaxError: cannot mix bytes and nonbytes literals
^bytes('mod wsgi Test Page\n', encoding= 'utf-8')
I get:
Error:[error]bytes('mod wsgi Test Page\\n', encoding= 'utf-8')
^ 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.
Larz60+ write Oct-04-2022, 12:52 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed (I think) for you this time (please review). Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed (I think) for you this time (please review). Please use BBCode tags on future posts.