View Single Post
Old May 26th, 2006, 6:45 AM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
CGI is the only alternative I have on my commercial host. I find it straightforward. Here's some snips:
print "Content-type: text/html\n\n"
import os
import cgitb; cgitb.enable()  #Debug aid to be removed later
import cgi
import re
import types
...
...
SERVER = os.environ
script = SERVER ['SCRIPT_NAME']
query = SERVER ['QUERY_STRING']
browser = SERVER ['HTTP_USER_AGENT']
ip = SERVER ['REMOTE_ADDR']
...
...
form = cgi.FieldStorage ()
page = form.getfirst ("page", "0-0")
...
That last statement gets the page field from the form or from a GET like "myurl?page=0-0&blah=blah". It gets the first, if there are more than one, and returns the second argument as a default if it isn't present.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote