/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import tornado.escape # or simplejson, etc import urllib class SimpleRequest(object): def __init__(self, path, args={}, post_args=None): self._path = path self._args = args self._post_data = post_args def read(self): post_data = None if self._post_data is not None: post_data = urllib.urlencode(self._post_data) path = "%s?%s" % (self._path, urllib.urlencode(self._args)) request = urllib.urlopen(path, post_data) try: response = tornado.escape.json_decode(request.read()) except: return False, -1 finally: request.close() return True, response @staticmethod def response(self, path, args={}, post_args=None): return SimpleRequest(path, args, post_args).read()
URL: http://www.alejandrob.com.ar/
Comments
