def senddata(self):
filename = "output.txt"
fileit = open(filename, 'r')
done = 0
while not done:
output = fileit.readline()
if output != "":
# 'text' is the value needed to be past to the php script to put in db
# the form name is text which is a textarea
params = urllib.urlencode({'text': output})
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
conn = httplib.HTTPConnection(linecache.getline('info.txt', 1))
conn.request("POST", "/filewrite.php", params, headers)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
else:
done = 1
fileit.close()
return True
评论列表
文章目录