Skip to content
Permalink
Browse files

ajout/modification de route

  • Loading branch information...
cexbrayat committed Aug 21, 2011
1 parent 77170a7 commit b74d5a2d7f21aad5f8a34d7493fc1b72ec075cf3
Showing with 11 additions and 3 deletions.
  1. +11 −3 app.js
14 app.js
@@ -28,10 +28,18 @@ app.configure('production', function(){

// Routes

// la liste des actions
var shares = [{name:"Google",price:120}, {name:"Apple",price:132}, {name:"Microsoft",price:92}];

// une route simple
app.get('/', function(req, res){
res.render('index', {
title: 'Express'
});
res.render('shares', {title : 'Shares', shares : shares});
});

// une route avec parametre
app.get('/:name', function(req, res){
res.render('shares', {title : req.params.name,
shares : shares.filter(function(share){return share.name.toLowerCase() == req.params.name.toLowerCase()})});
});

app.listen(3000);

0 comments on commit b74d5a2

Please sign in to comment.
You can’t perform that action at this time.