[CGI] Why is HTML not rendered?

Gilles nospam at nospam.com
Fri Aug 17 09:27:59 EDT 2012


Hello

	I'm learning how to call Python scripts through the different
solutions available.

For some reason, this CGI script that I found on Google displays the
contents of the variable but the HTML surrounding it is displayed
as-is by the browser instead of being rendered:

--------------
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

import cgi
form = cgi.FieldStorage()

# get a value from the form
value = form.getvalue("dummy")

print "Content-Type: text/plain;charset=utf-8"
print

# print a document
print "<P>You typed: <TT>%s</TT></P>" % (
    cgi.escape(value),
    )
--------------

Here's the output:
--------------
<P>You typed: <TT>test</TT></P>
--------------

Could this be due to the script itself, or some server configuration?

Thank you.



More information about the Python-list mailing list