[medusa] Trouble with the CGI
rprice@u...
rprice@u...
Tue, 10 Apr 2001 09:24:13 -0700 (PDT)
It's been a while since I've workd with cgi.py but I believe your problem is in
reading datos['name']. Try datos['name'].value instead. datos['name'] may
contain a list or string, so adapt your code accordingly.
Ray
Quoting Ernesto Nadir Crespo Avila <ecrespo@u...>:
> 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
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>