X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fjcalderonzumba%2Fgastonjs%2Fexamples%2Fnodejs%2Fmain.js;fp=vendor%2Fjcalderonzumba%2Fgastonjs%2Fexamples%2Fnodejs%2Fmain.js;h=1ba7e5618528168e0e96ccc4c3cbd08a1e48d898;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/jcalderonzumba/gastonjs/examples/nodejs/main.js b/vendor/jcalderonzumba/gastonjs/examples/nodejs/main.js new file mode 100644 index 000000000..1ba7e5618 --- /dev/null +++ b/vendor/jcalderonzumba/gastonjs/examples/nodejs/main.js @@ -0,0 +1,37 @@ +"use strict"; +var http = require("http"); + +var visitCommand = JSON.stringify({name: 'visit', args: ['http://www.google.es']}); +var renderCommand = JSON.stringify({name: 'render', args: ['/Users/juan/Downloads/page_image.png', true, null]}); + +var postOptions = { + host: '127.0.0.1', + port : 8510, + path: '/api/v1', + method: 'POST', + headers: { + 'Content-type': 'application/json', + 'Content-Length': visitCommand.length + } +}; + +var postRequest = http.request(postOptions, function(res){ + res.setEncoding('utf8'); + res.on('data', function(chunk){ + console.log(chunk); + }); +}); + +postRequest.write(visitCommand); +postRequest.end(); + +postOptions.headers['Content-Length']=renderCommand.length; +postRequest = http.request(postOptions, function(res){ + res.setEncoding('utf8'); + res.on('data', function(chunk){ + console.log(chunk); + }); +}); + +postRequest.write(renderCommand); +postRequest.end();