Simple CGI request and Python reply

Greg Corradini gregcorradini at gmail.com
Wed Apr 8 10:52:24 EDT 2009


Hello,
I'm trying to implement something very simple without using a Python
WebFramework and I need some advice. I want to send a comma delimited string
from the client to a server-side Python script. My initial plan was to use a
JavaScript function (see below) called "makerequest" that creates a
XMLHttpRequest object and GETs the output from a Python script. I've used
this function before to field requests  (in those cases the parameter "data"
passed in the XMLHttpRequest.send() method is null). So I thought I could
just pass some data in and be able to retrieve it with Python. I'm not sure
how to do this. I've used forms with cgi/Python before. However, I don't
want to use a form here. I want Python to handle the "data" variable being
passed without looking for field names using .FieldStorage(). Can that be
done?

Maybe making a request is not the quickest route to do what I want.  Ideas?

function makerequest(serverPage,objID,data)
{
	var obj = document.getElementById(objID);
	xmlhttp.open("GET",serverPage);
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(data);
}


-- 
View this message in context: http://www.nabble.com/Simple-CGI-request-and-Python-reply-tp22952274p22952274.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list