-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
48 lines (38 loc) · 1.03 KB
/
server.js
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
37
38
39
40
41
42
43
44
45
46
47
48
// Node server for the Dune board game
var express = require("express");
var app = express();
setViews();
registerJadeFileExtensionHook();
setStaticFileServerDirectory();
setUrlPathRedirect();
listenForIncomingRequests();
function setViews() {
setViewsDirectory();
setViewsEngine();
}
function setViewsDirectory() {
app.set("views",__dirname + "/views");
}
function setViewsEngine() {
// *.html files in views directory will open with jade template system
app.set("view engine","jade");
}
function registerJadeFileExtensionHook() {
// Register *.jade files to open using the jade template system
app.engine("jade", require("jade").__express);
}
function setStaticFileServerDirectory() {
// for css, js, images
app.use(express.static(__dirname + "/public"));
}
function setUrlPathRedirect() {
app.get("/", function(req, res) {
res.render("index");
});
}
function listenForIncomingRequests() {
var port = 3000;
app.listen(port);
console.log("Running Dune Board Game server");
console.log("Listening on port " + port);
}