Created
December 23, 2015 17:55
-
-
Save jonasalmeida/d85c47b0808e76c0eb68 to your computer and use it in GitHub Desktop.
Service running at https://i2workshop.azurewebsites.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
var port = process.env.PORT || 1337; | |
http.createServer(function(req, res) { | |
res.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Access-Control-Allow-Origin': '*' // CORS | |
}); | |
if(req.url.match('=')){ | |
var pp=req.url.slice(2).split('=') // parameter array | |
var parm={} | |
for(var i=0;i<pp.length;i=i+2){ | |
parm[pp[i]]=pp[i+1] | |
} | |
var y=[] | |
var n = parseFloat(parm.n) | |
console.log(new Date(),'n=',n) | |
for(var i=0;i<n;i++){ | |
y.push(Math.random()) | |
} | |
console.log(parm) | |
res.end(JSON.stringify(y)); | |
}else{ | |
res.end('please provide value of parameter n to set length of random vector\nfor example https://'+req.headers.host+'?n=10') | |
} | |
}).listen(port); | |
console.log('listening to port '+port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment