var express = require('express');
var app = express();
app.set('view engine', 'ejs');
app.locals.pagetitle = "Awesome Website";
app.get('/', function(req, res) {
console.log('/ requested');
res.render('default', { title: 'Hello', content: 'Heyyy salut-donc !', users: ['Mireille', 'José', 'Marcel', 'Odette', 'Lucien', 'Félicienne'] });
})
// si on a autre chose
app.get('*', function(req, res) {
console.log('Page inconnue demandée');
res.render('default', { title: '😭', content: '😭😭😭'});
})
var server = app.listen(3000, function() {
console.log('Listening on port 3000.');
})
=== default.ejs ===
<% include partials/head.ejs %>
<%= pagetitle %> - <%= title %>
<%= content %>
<% if (typeof(users) !== 'undefined') { %>
<% for (var i=0; i
- <%= users[i] %>
<% } %>
<% } %>