I am using Python 2.5 r25:51908 MSC v.1318 32 bit (Intel) on wind32 I am totally new to Python and started yesterday going over a couple of examples I found in the documentation which address a problem I am trying to solve.
I have successfully opened a file and read the results adapting this code snippit: >>> f = open('/tmp/workfile', 'w') >>> print f <open file '/tmp/workfile', mode 'w' at 80a0960> >>> f.read() 'This is the entire file.\n' >>> f.close() Then I tried to POST something to a cgi sytle script on my test website. Below is the code I used, I type it in one line at time to make sure I am doing it correctly. I am confused about how to format several of the lines in the below script. on the params line the name / value pair I want to send is name = 'textarea1' value = 0 on the conn line I put "thenational.us' as the domain on the conn.request line I put the web path to the html page (getpost.html) that processes the POST The data is not being posted to the webpage. Concerning the conn.request line, "/pages/" is what I call the cgi-bin directory, "start" is the name of the cgi script I use (no ext), "/test/ getpost.html" is the web path to the page that accepts the POST. I do not use GET because the data will be several k or larger in size when I get it all working correctly. >>> import httplib, urllib >>> params = urllib.urlencode({'textarea1': 0}) >>> headers = {"Content-type": "application/x-www-form-urlencoded", ... "Accept": "text/plain"} >>> conn = httplib.HTTPConnection("thenational.us:80") >>> conn.request("POST", "/pages/start/test/getpost.html", params, headers) >>> response = conn.getresponse() >>> print response.status, response.reason 302 Found >>> data = response.read() >>> conn.close() My project I want to learn how to do is; I have data coming from an external device over a com port that I manually download and save to a file on my home computer with the manufacturer's software. I then want to move that data to my webserver where others can view the data from a webpage. My goal is to open a file on my home computer and load the contents of that file to my website where I will store the data and display it. I could just copy the file to the webserver that would accomplish the same thing as posting it as a var and saving that to a file on the server. Howerver, I am trying to automate the process as much as possible with Python as when an event is happening, new data is coming in over a period of seveal hour from the external device over the com port. Is there a better solution than POST -- http://mail.python.org/mailman/listinfo/python-list