Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created July 20, 2013 11:19
Show Gist options
  • Save thekarel/6044681 to your computer and use it in GitHub Desktop.
Save thekarel/6044681 to your computer and use it in GitHub Desktop.
Node.js server basic
// Run with node server.js
var cfg = {
http: {
port: 3333,
host: '127.0.0.1'
}
}
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-type': 'text/plain'});
res.end('Hello World!\n');
}).listen(cfg.http.port, cfg.http.host);
console.log('Server up on', cfg.http.host, cfg.http.port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment