mardi 27 janvier 2015

[Python] Tornado - send POST parameters in the body with AsyncHTTPClient

If you want to send POST data to an URL(a RESTful web service for example) with AsyncHTTPClient, you can do that :

import urllib
post_data = { 'data': 'test data' } #A dictionary of your post data
body = urllib.urlencode(post_data) #Make it into a post request
http_client = tornado.httpclient.AsyncHTTPClient()
http_client.fetch("http://127.0.0.1:8888", handle_request, method='POST', headers=None, body=body)
Link : http://stackoverflow.com/questions/10367981/how-to-use-post-method-in-tornado

Categories