Ok, I was interested and having fun looking this up, so I made a small demo page... You can find it running
here
The actual code for that is:
Code:
#!/usr/bin/python
import cgi
def main():
print "Content-type: text/html\n\n" #necessary!!! without this it wont work
form=cgi.FieldStorage() #initialize the form storage for getting data from the user
name=form.getfirst("name") #get the name from the user (through the form)
if name != None:
name=nameProcess(name) # save processed name
else:
name="No name input :(" #no name given...
# This is the actual page:
print """
<html>
<head>
<title>Name Perioder</title>
</head>
<body>
<h1>%s</h1>
<form action="" method="get">
<input type="text" name="name">
<input type="submit">
</form>
</body>
</html>""" % name #string formatting - insert the name into the page
def nameProcess(orig): #function to be called on user input. Inserts a dot after each letter.
final=""
for a in orig:
final+=a+"."
return final
if __name__ == "__main__": #checks to make sure that this page isn't included by another. if it is, we wouldn't want it to print the contents of main().
main()
Not the most elegant, but I think it illustrates the basic point.