[Tutor] Help with 500 error on cgi script

Pedro Diaz Jimenez pdiaz88@terra.es
Sun, 18 Mar 2001 11:51:13 +0100


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Remember to put the "Content-type: text/html" line first?

Every cgi has to inform about the content is going to show since that cannot 
be know by the webserver. In every CGI you make, the golden rule is:

Start with:
print "Content-type: text/html\n"

Cheers

Pedro

On Sunday 18 March 2001 10:33, Sheila King wrote:
> OK, I'm at my wits end.
>
> I have Apache running on my local Win98 machine, and I have one simple
> python cgi script, equivalent to "Hello, World!", that I have been able to
> run.
>
> Today I thought I would start to play with the cgi module and start doing
> some forms and so forth.
>
> Well, I was getting 500 internal server errors. I've checked everything.
> The path, etc...
>
> So, finally, I tried just running cgi.test(), as recommended in the Python
> tutorial. It worked splendidly.
>
> I also have the Python Core Programming book, from Wesley Chun, that comes
> with a CD-ROM and I put up his friends.htm and friends1.py files from the
> CD onto my local site, and it ran just fine, also.
>
> I've compared my file to the other two files and just can't see what I'm
> doing wrong.
>
> So, here is my script. I'm sure someone here will see it right off?
>
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
>
>
> #!/usr/bin/env python
>
>
> import cgi
>
> form = cgi.FieldStorage()
> form_ok = 0
>
> if form.has_key("subscriberEmail") and form.has_key("command"):
>     form_ok = 1
> if not form_ok:
> 	output = '''Content-type: text/html\n\n
> <html>
> <Head>
> <Title>Error in Form</Title>
> </Head>\n
> <Body>\n
> <H1>Error</H1>
> You have not filled out all necessary information to complete this request
> You <b>MUST</b> fill in your subscriber e-mail in the From: box
> and you <b>MUST</b> select some action to modify your delivery options.
> Please use the back button on your browser to return to the form and fill
> in the required information
> </body>\n</html>
> '''
> 	print output
> else:
> 	for k in form.keys():
>     	print k, " : ", form[k]
> 	print "All done!"
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6tJMqnu53feEYxlERAvNXAKDRCEhW5UCIt8xVtMaJYVb2wuUNcgCgzl//
GMBCEP1FJEwLqrD15RblXYo=
=Vcx+
-----END PGP SIGNATURE-----