All, I have a Python program that makes images of data and I want to be able to make these via a web interface. I want to keep it simple so I thought I would send an XML file to a cgi program (XML is what I am supposed to use). I have the parsing of the XML all figured out but the way I am sending the XML and receiving it does not look like they are the best ways.
I have an HTML form that I use to collect input on what kind of image. I then take that form input and make it into an XML string. I then take that XML string and POST it to a CGI script. I am using cgi to retrieve the XML string. Once I have the string I get the needed info and make an image. The Part that just does not look right to me is using form = cgi.FieldStorage() Of someone else wanted to just post an XML string they would have to have the same form name "XMLhttp" that is not very user friendly. My guess is I am missing something about how cgi can work. I bet Python has a simple way to receive a XML post so I do not have to look for a specific form name? Any help would be appreciated. Thanks, John Web page code to post XML in a text area <form action="http://......../cgi-bin/parsXML2.py" target=text/xml method=post> <TEXTAREA cols=60 name="XMLhttp" rows=20 wrap=Real> <?xml version="1.0" ?> <StatRequest requestID="user-20070531-Time"> </StatRequest> </TEXTAREA> <INPUT type=submit value="Submit Query"> </FORM> Code that receives the XML POST form = cgi.FieldStorage() if not (form.has_key("XMLhttp")): print "content-type: text/html\n\n" print "<H1>Error</H1>" else: xmlString = form["XMLhttp"].value print "content-type: text/html\n\n" req = ParseXML()
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor