NODEJS get server info nodejs - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution
join us

get server info using nodejs


 599

NODEJS


3

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


By        
The power of the user (%)
8%



The most helpful NODEJS solutions

get user ipget user ipNODEJS

Click to see more ...

  6.8K     1.7K

how to get client netmask using node.js ?how to get client netmask using node.js ?NODEJS

Click to see more ...

  3.8K     557

How to get client machine name and computer name with node.js?How to get client machine name and computer name with node.js?NODEJS

Click to see more ...

  10.7K     437

how to get client local ip address using node.js ?how to get client local ip address using node.js ?NODEJS

Click to see more ...

  2K     311

How to get client ip address using node.jsHow to get client ip address using node.jsNODEJS

Click to see more ...

  1.7K     271

How to combine node.js and jquery ?How to combine node.js and jquery ?NODEJS

Click to see more ...

  1.3K     247

how to detect tablet, iPad, iPhone, Android and Blackberry using nodejs ?how to detect tablet, iPad, iPhone, Android and Blackberry using nodejs ?NODEJS

Click to see more ...

  1.6K     161

get client region using node.js ?get client region using node.js ?NODEJS

Click to see more ...

  1.2K     128

get real user ip address using node.js?get real user ip address using node.js?NODEJS

Click to see more ...

  809     124

get server ip address from hostname nodejsget server ip address from hostname nodejsNODEJS

Click to see more ...

  2.4K     122

Welcome aboard!
We are happy you are here and
wish you good net-raft!