Skip to content

Instantly share code, notes, and snippets.

@tj
Created February 19, 2012 01:34
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 tj/1861551 to your computer and use it in GitHub Desktop.
Save tj/1861551 to your computer and use it in GitHub Desktop.
meow
var express = require('./')
, app = express();
var users = [];
users.push({ name: 'Tobi' });
users.push({ name: 'Loki' });
users.push({ name: 'Jane' });
app.get('/', function(req, res){
res.respondTo({
'text/html': function(){
res.send('<ul>' + users.map(function(user){
return '<li>' + user.name + '</li>';
}).join('') + '</ul>');
},
'text/plain': function(){
res.send(users.map(function(user){
return ' - ' + user.name + '\n';
}).join(''));
},
'application/json': function(){
res.json(users);
}
})
});
app.listen(3000);
console.log('listening on port 3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment