Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2008, 07:50
VelvetRevolver
(Desactivado)
 
Fecha de Ingreso: julio-2008
Mensajes: 14
Antigüedad: 15 años, 9 meses
Puntos: 0
python, CGI y las paginas web!!

Para procesar la info. de un form html en un script python, el servidor tiene que tener habilitado el interprete para python verdad???? Y si esta habilitado, el script podria ser algo asi???

Cita:
<?python

#!/usr/bin/python2.5
#
######### don't change the following three lines: ###########
import cgi
print "Content-Type: text/html\n"
form = cgi.FieldStorage()

## add a form.getvalue for each of the names in your form: ##
drink = form.getvalue("drink")

########## start of HTML code ###########
print """
<html>
<head> <title>What would you like to drink</title> </head>
<body>
<h4>Your drink: </h4><p>
"""
############ end of HTML code #############

if drink == "tea":
print "You requested tea"
elif drink == "coffee":
print "You requested coffee"
elif drink == "hot chocolate":
print "You requested hot chocolate"
else:
print "You need to select a drink!"


########### start of HTML code ###########
print """
<p>Thank you for your visit. Please come again. <p>
</body></html>
"""
############# end of HTML code ##############

?>
GRACIAS!!!