Simple CGI request and Python reply

Discussion in 'Python' started by Greg Corradini, Apr 8, 2009.

  1. 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.
    Greg Corradini, Apr 8, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bert
    Replies:
    1
    Views:
    578
    jmm-list-gn
    Sep 17, 2004
  2. davidj411
    Replies:
    1
    Views:
    1,032
    Mike Driscoll
    May 27, 2008
  3. Replies:
    2
    Views:
    549
  4. Doug Miller
    Replies:
    18
    Views:
    289
    Doug Miller
    Sep 27, 2007
  5. Ethan Furman
    Replies:
    0
    Views:
    155
    Ethan Furman
    Aug 24, 2012
Loading...

Share This Page