Created
August 20, 2010 06:22
-
-
Save mystix/539728 to your computer and use it in GitHub Desktop.
NodeJS scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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