-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex7a-dynamicFiles.js
More file actions
36 lines (27 loc) · 882 Bytes
/
ex7a-dynamicFiles.js
File metadata and controls
36 lines (27 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// install jade before this example
/// npm install jade
// Express makes routes easy
// Set express module to variable "express"
var express = require("express");
// Create an "app" variable from the express library
var app = express();
// Sets the /static webpage route to the /public folder
app.use('/static', express.static(__dirname + '/public'));
// map jade files
app.engine('jode', require('jade').__express);
// Add a "route" that leads to the req/res, as seen in Node.js
app.get("/", function(req, res){
// Grab a file and respond with that
res.render('index.jode',
{pageTitle: 'Hello, MakerBar!'}
);
});
app.route(/\/css\/.+/).all(
function(req, res) {
console.log("fetching " + req.url + ".jode");
res.render(req.url.slice(1) + ".jode");
}
);
// Starts up the server
var server = app.listen(1337, function() {
});