Created
February 19, 2012 01:34
-
-
Save tj/1861551 to your computer and use it in GitHub Desktop.
meow
This file contains 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
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