Version 1
[yaffs-website] / vendor / jcalderonzumba / gastonjs / examples / python / main.py
diff --git a/vendor/jcalderonzumba/gastonjs/examples/python/main.py b/vendor/jcalderonzumba/gastonjs/examples/python/main.py
new file mode 100644 (file)
index 0000000..53c8f19
--- /dev/null
@@ -0,0 +1,18 @@
+import httplib
+import json
+
+__author__ = 'juan'
+
+connection = httplib.HTTPConnection('127.0.0.1', 8510)
+headers = {'Content-type': 'application/json'}
+command = {'name': 'visit', 'args': ['http://www.google.es']}
+
+jsonCommand = json.dumps(command)
+connection.request('POST', '/v1/api', jsonCommand, headers)
+response = connection.getresponse()
+print(response.read().decode())
+command = {'name': 'render', 'args': ['/Users/juan/Downloads/page_image.png', True, None]}
+jsonCommand = json.dumps(command)
+connection.request('POST', '/v1/api', jsonCommand, headers)
+response = connection.getresponse()
+print(response.read().decode())