Welcome aboard! We are happy you are here and wish you good net-raft!
var http = require('http');
var os = require('os');
var url = require('url');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var parse_url = url.parse(req.url).pathname.replace(/.*\/|\.[^.]*$/g, '');
if( parse_url === "all"){
Object.keys(os).map(function(method) { res.write(method+":"+JSON.stringify(os[method](),2,true))+","; })
}
else{
try{
var result = os[parse_url]();
res.write(JSON.stringify(result),'utf8');
}
catch(e){
res.end("try : " + Object.keys(os).join(", "));
}
}
res.end();
}).listen(3000, "localhost");
console.log('Server running at http://localhost:3000/');
// type http://localhost:3000/cpus into a browser
or arch, EOL, endianness, freemem, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpdir, totalmem, type, userInfo, uptime, getNetworkInterfaces, tmpDir
The most helpful NODEJS solutions
get user ipNODEJS Click to see more ... 7.6K 1.7K