471,337 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

serving html from a python script in IE

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.

Nov 1 '07 #1
4 1476
On Nov 1, 9:52 am, bluegray <bluegraydra...@gmail.comwrote:
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

Nov 1 '07 #2

"bluegray" <fr************@gmail.comwrote in message
news:11**********************@k35g2000prh.googlegr oups.com...
print "Content-Type: application/xhtml+xml
That's your problem. You can't use that Mime type
because IE doesn't support XHMTL. No "appendix C"
hair splitting comments, please.
Nov 1 '07 #3
bluegray 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.

If you take out the space between text/html and ; it works just fine.

(In other words, there is no mime-type "text/html ")

Cheers,
Cliff

Nov 1 '07 #4
If you take out the space between text/html and ; it works just fine.
>
(In other words, there is no mime-type "text/html ")
Thanks! That did it. What a difference a space makes ;)

Nov 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by -[ CaMeL ]- a55m0nk | last post: by
1 post views Thread by Matthew Flower | last post: by
21 posts views Thread by Nicholas Sherlock | last post: by
4 posts views Thread by dreadrocksean | last post: by
3 posts views Thread by Sander Tekelenburg | last post: by
2 posts views Thread by AeonOfTime | last post: by
4 posts views Thread by iceanfire | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.