Skip to content

Instantly share code, notes, and snippets.

@mystix
Created August 20, 2010 06:22
Show Gist options
  • Save mystix/539728 to your computer and use it in GitHub Desktop.
Save mystix/539728 to your computer and use it in GitHub Desktop.
NodeJS scripts
// ExpressJS - Hello World! example
var express = require('express'),
app = express.createServer();
app.get('/', function(req, res) {
res.redirect('/hello/world');
});
app.get('/hello/world', function(req, res) {
res.send('Hello World');
});
app.listen(3030);
console.log('expressjs app listening on localhost:3030');
#!/bin/bash
# Installs NodeJS, npm, ExpressJS + required depencies & other useful stuff via Homebrew
brew install node npm
npm install express jade sass less
# install db bindings
npm install postgres mongodb
# install node-inspector
npm install node-inspector
// NodeJS - Hello World! example
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
console.log(req.url);
console.log(req.headers['user-agent']);
}).listen(8124, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8124/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment