Unicode in cgi-script with apache2
Dominique Ramaekers
dominique at ramaekers-stassart.be
Sat Aug 16 18:39:51 EDT 2014
Hi John,
The error is in the line "print(line,end='')"... and it only happens
when the script is started from a webbrowser. In the terminal, the
script works fine.
See my previous mail for my findings after a lot of reading and trying...
grz
Op 15-08-14 om 21:32 schreef John Gordon:
> In <mailman.13038.1408130249.18130.python-list at python.org> Dominique Ramaekers <dominique at ramaekers-stassart.be> writes:
>
>> #!/usr/bin/env python3
>> print("Content-Type: text/html")
>> print("Cache-Control: no-cache, must-revalidate") # HTTP/1.1
>> print("Expires: Sat, 26 Jul 1997 05:00:00 GMT") # Date in the past
>> print("")
>> f = open("/var/www/cgi-data/index.html", "r")
>> for line in f:
>> print(line,end='')
>> If access the script through a webbrowser, apache gives an error:
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
>> 1791: ordinal not in range(128)
> The error traceback should display exactly where the error occurs within
> the script. Which line is it?
>
More information about the Python-list
mailing list