On Oct 26, 2006, at 12:23 PM, 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?
There is no single answer. It's been said that there are more web
frameworks in Python than there are keywords, and if that is an
exaggeration, it isn't a very big one.
Why is that? Because Python makes it brain-dead simple to create
your own webserver. Here's one:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
import BaseHTTPServer
import CGIHTTPServer
class MyHandler(CGIHTTPServer.CGIHTTPRequestHandler):
def __init__(self, *args, **kwargs):
CGIHTTPServer.CGIHTTPRequestHandler.__init__(self,
*args, **kwargs)
def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=MyHandler):
server_address = ("", 8080)
handler_class.cgi_directories = ["/cgi-bin"]
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
run()
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This will listen on port 8080, and serve up files in the current
directory. If you want scripts, including forms processing, create a
Python script and put it in the 'cgi-bin' directory (you can call
this whatever you like), and then set your form's action to '/cgi-bin/
whil.py'. That script will get all of the form values, and you can do
whatever you like with them.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
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.