No puedo acceder a variables enviadas por POST
Luis Garcia Merino
lgmerino en yahoo.com
Mie Abr 16 21:43:37 CEST 2008
Hola,
estoy intentando leer variables enviadas desde un formulario en HTML por POST (por GET no tengo problemas), pero no hay manera. Tengo instalado lighttpd, fastcgi con flup y Python 2.5 (aunque también lo he probado con 2.4).
El HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="post" action="http://localhost/index.fcgi" name="formulario">
<input type="text" value="pwp" name="ambito" />
<input type="text" value="pwp2" name="ambito2" />
<input type="text" value="354353" name="ambito3" />
<input type="submit" />
</form>
</body>
</html>
Y el programa en Python que recibe la petición (lo que sería el WSGI dispatcher):
#!/usr/bin/python2.5
# -*- coding: UTF-8 -*-
import cgi
from flup.server.fcgi import WSGIServer
def myapp( environ, start_response ):
form = cgi.FieldStorage()
start_response('200 OK', [('Content-Type', 'text/html')])
strCampos =""
for campo in form.keys():
strCampos = strCampos + "," + campo + "<br/>"
yield "<p>"
yield "Longitud: " + str(len(form)) + "<br/>" + strCampos
yield "</p>"
WSGIServer(myapp).run()
El resultado que obtengo al hacer submit es:
<p>Longitud: 0<br/></p>
Llevo unos cuantos días atascado con esto y no sé qué puede ser. Gracias por adelantado.
Un saludo,
Luis
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
Lista de correo Python-es
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes
Más información sobre la lista de distribución Python-es