S60 Http Post Python
Join the DZone community and get the full member experience.
Join For FreeFrom (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/
Python (language)
POST (HTTP)
Opinions expressed by DZone contributors are their own.
Trending
-
Structured Logging
-
Effective Java Collection Framework: Best Practices and Tips
-
Microservices With Apache Camel and Quarkus
-
Microservices With Apache Camel and Quarkus (Part 2)
Comments