Trouble with the CGI

Ernesto Nadir Crespo Avila ecrespo@u...
Tue, 10 Apr 2001 07:19:55 -0400


I Canīt get the values passed to a web page, even that I tried the methods
Get and Post, the results were:


With POST:

The Pageīs structure itīs the following:

<form action="./cgi-bin/ej4.mpy" method="POST" ><input type="text"
name="name" size="15" maxlength="15">
<input type="submit" name="OK" value="ok">
</form>

The cgi "ej4.mpy" is:

# -*- Mode: Python; tab-width: 4 -*-
# send and process a POST form
import sys, cgi

print '<html>'
print '<head>'
print '<meta http-equiv="Content-type" content="text/html">'
print
print '<title> A Phyton Example</title>'
print '</head>'
print '<body>'
datos = sys.stdin.read()

if datos:
print '<h1> The name is: %s</h1>' % repr(cgi.parse_qs(datos)
else:
print '<h1> Thereīs no data .</h1>'
print '</body>'
print '</html>'

The message returned by this method
Error response
Error code 500.
Message: Internal Server Error.

The Log message:
127.0.0.1:1119 - - [10/Apr/2001:01:21:59 -0400] "POST
/webconflrp/cgi-bin/ej4.mpy HTTP/1.1" 500 289

*****************************************************************************
***** The Method Get
The Pageīs structure itīs the following:

<form action="./cgi-bin/ej5.mpy" method="GET" >
<input type="text" name="name" size="15" maxlength="15">
<input type="submit" name="OK" value="ok">
</form>

The cgi "ej4.mpy" is:

# -*- Mode: Python; tab-width: 4 -*-
# send and process a POST form
import cgi
print '<html>'
print '<head>'
print '<meta http-equiv="Content-type" content="text/html">'
print
print '<title> A Cgi example with Phyton</title>'
print '</head>'
print '<body>'
datos = cgi.FieldStorage()

if datos.has_key('name'):
print '<h1> Your data: %s</h1>' %datos['name']
else:
print 'thereīs no data'
print '</body>'
print '</html>'

The page waits a lot of time for loading and the log returned:
127.0.0.1:1138 - - [10/Apr/2001:01:49:49 -0400] "GET
/webconflrp/cgi-bin/ej5.mpy?name=ernesto HTTP/1.1" 500 116

How can I solve this?
Thank you all in advance!

Bye, Ernesto Crespo