[Tutor] CGI and other stuff
David Porter
jcm@bigskytel.com
Mon, 13 Nov 2000 20:10:17 -0700
* D-Man <dsh8290@rit.edu>:
> I'm trying to write a couple of cgi scripts to dynamically create some web
> pages. I have finally figured out how to access the query string. Now I
> would like some suggestions as to the best way to parse it. The parsing
> method as well as the format of the string is completely at my discretion.
If I understand you correctly, something like this is what you want:
import cgi
form = cgi.FieldStorage()
Then you can use form as you would a dictionary with key/value pairs:
if form.has_key("edit"):
if form["edit"].value == "add":
add_node()
elif form["edit"].value == "delete":
delete_node()
http://url/script?edit=add would then cause the function add_node() to run.
hth,
David