53c8f19319ebcaa11bd46cc2bdd95e9ebb9acf89
[yaffs-website] / vendor / jcalderonzumba / gastonjs / examples / python / main.py
1 import httplib
2 import json
3
4 __author__ = 'juan'
5
6 connection = httplib.HTTPConnection('127.0.0.1', 8510)
7 headers = {'Content-type': 'application/json'}
8 command = {'name': 'visit', 'args': ['http://www.google.es']}
9
10 jsonCommand = json.dumps(command)
11 connection.request('POST', '/v1/api', jsonCommand, headers)
12 response = connection.getresponse()
13 print(response.read().decode())
14 command = {'name': 'render', 'args': ['/Users/juan/Downloads/page_image.png', True, None]}
15 jsonCommand = json.dumps(command)
16 connection.request('POST', '/v1/api', jsonCommand, headers)
17 response = connection.getresponse()
18 print(response.read().decode())