On 8/17/12 2:27 PM, Gilles wrote:
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?

By using "Content-Type: text/plain", you told the browser to treat it like plain text instead of HTML. Use text/html instead.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to