DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

S60 Http Post Python

05.15.2006
| 6629 views |
  • submit to reddit
        From (http://www.python.org/doc/current/lib/httplib-examples.html)

==
import httplib, urllib

# replace with whatever you want POSTed...
gps_coords = urllib.urlencode({'param_1': 'value_1', 'param_2': 'value_2'})

# form contents
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPConnection("location-server.com:80")
conn.request("POST", "/cgi-bin/collect_loc", gps_coords, headers)
response = conn.getresponse()
data = response.read()
conn.close()
==

Both httplib and urllib are shipped with PyS60. Of course, you will have to create the CGI script separately.

Cheers,
Sandeep
http://sandeep.weblogs.us/