serving html from a python script in IE

kyosohma at gmail.com kyosohma at gmail.com
Thu Nov 1 11:51:16 EDT 2007


On Nov 1, 9:52 am, bluegray <bluegraydra... at gmail.com> wrote:
> I'm writing a script that outputs html. It works fine in Firefox,
> however, IE wants to download the file instead of displaying the
> output. I keep getting the file download dialog instead of the html
> page.
>
> I am doing something like this:
>
> print 'Content-Type: text/html ; charset=utf-8\nCache-Control: no-cache
> \n'
> print '<html><body>some text and html</body></html>'
>
> I also tried various things in .htaccess which has the following line:
>
> AddHandler cgi-script .py
>
> Any help will be appreciated.

Do you have the "shebang" listed at the top of your code (i.e. #!/path/
to/python)? Are you importing the cgi module at the top of your code?

>From what I've read, you don't need to modify the htaccess file...

See also:

Tutorials:
http://www.cs.virginia.edu/~lab2q/
http://wiki.python.org/moin/CgiScripts
http://www.upriss.org.uk/python/PythonCourse.html

Docs:
http://www.python.org/doc/essays/ppt/sd99east/index.htm
http://docs.python.org/lib/module-cgi.html

Mike




More information about the Python-list mailing list