diff --git a/routes/api.js b/routes/api.js index 4029cca..0e68e1b 100644 --- a/routes/api.js +++ b/routes/api.js @@ -14,7 +14,7 @@ var ip2name = {}; var lxcTimeout = function(ip, time){ var name = ip2name[ip]; - console.log(name); + console.log(name) time = time || 900000; // 15 minutes var keys = Object.keys(timeoutEvents) if(keys.indexOf(name) !== -1){ @@ -31,14 +31,17 @@ var runner = function(req, res, ip){ console.log('ip:', ip); lxcTimeout(ip); console.log('code to run:', '\n'+req.body.code); - return request.post({ - url: 'http://'+ip+':15000', + + var httpOptions = { + url:'http://' + ip + ':15000', body: JSON.stringify({ code: req.body.code }) - }, function(error, response, body){ - console.log('arguments:\n', arguments); - // body = JSON.parse(body); + }; + + return request.post(httpOptions, function(error, response, body){ + console.log('body:\n', body); + body = JSON.parse(body); body['ip'] = ip.replace('10.0.', ''); return res.json(body); });