Whil Hentzen (Pro*) wrote:
Not ever even tried to do any Web-oriented stuff with Python, how would
you do the typically simple 'form 1 - display text boxes and a form
action button', 'form 2 - GET those vars and display the results' type
of thing in Python? What's required to be on the server?
Here is one way. Nothing special here, just basic CGI scripting. Only
requirements are webserver and standard python installation. This is
not what we use, I will post that when I get back from lunch.
*** param_test.html ***
<html>
Check parameters
<form action="cgi-bin/param_test.py" method="POST">
param1:<input type="text" name="p1"><br>
param2:<input type="text" name="p2"><br>
param3:<input type="text" name="p3"><br>
<input type="submit">
</form>
</html>
*** param_test.py ***
#!/usr/bin/env python
import cgi
def generate_error():
print "error..."
def display_data(p1, p2, p3):
print "Parameter1 is "+ p1 + "\n"
print "Parameter2 is "+ p2 + "\n"
print "Parameter3 is "+ p3 + "\n"
print "Content-Type: text/html\n\n"
form = cgi.FieldStorage()
if (form.has_key("p1") and form.has_key("p2") and form.has_key("p3")):
display_data(form["p1"].value, form["p2"].value, form["p3"].value)
else:
generate_error()
Casey
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.