Skip to content

Instantly share code, notes, and snippets.

@robdodson
Created May 28, 2012 18:52
Show Gist options
  • Save robdodson/2820624 to your computer and use it in GitHub Desktop.
Save robdodson/2820624 to your computer and use it in GitHub Desktop.
pickle store!
// Routes
var count = 100;
app.get('/', function(req, res) {
res.send('Welcome to the Pickle Store!');
});
app.get('/pickles', function(req, res) {
res.json({
count: count,
message: 'oh boy, ' + count + ' pickles!'
});
});
app.get('/pickles/add/:num', function(req, res) {
count += parseInt(req.params.num);
res.json({
add: req.params.num,
message: 'you added ' + req.params.num + ' pickles to the pickle barrel!'
});
});
app.listen(3000, function(){
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment