Skip to content

Instantly share code, notes, and snippets.

@fdomig
Created March 24, 2011 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fdomig/884772 to your computer and use it in GitHub Desktop.
Save fdomig/884772 to your computer and use it in GitHub Desktop.
A sample node.js sensor
var argv = require('optimist').argv;
var http = require('http');
var temp = function() {
return '17';
}
http.createServer(function(req, res) {
console.log(req.method + " " + req.url + ' HTTP/' + req.httpVersion);
res.writeHead('200', {'Content-Type': 'text/plain'});
res.end(temp());
}).listen(argv.port, argv.ip);
console.log('Server started at http://' + argv.ip + ':' + argv.port + '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment