-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (41 loc) · 863 Bytes
/
server.js
File metadata and controls
47 lines (41 loc) · 863 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
37
38
39
40
41
42
43
44
45
46
47
var express = require("express");
var app = express();
app.use(express.static("public"));
app.set("views", __dirname + "/views");
app.set("view engine", "pug");
function daysInMonth(month) {
var year = new Date().getFullYear();
return new Date(year, month, 0).getDate();
}
var months = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
];
var grid = {};
for (var i = 0; i < months.length; i++) {
grid[months[i]] = daysInMonth(i + 1);
}
var moodOptions = {
5: "amazing",
4: "great",
3: "average",
2: "difficult",
1: "tough",
0: "none",
};
app.get("/", function (req, res) {
res.render("index", { grid: grid, moodOptions: moodOptions });
});
var listener = app.listen(process.env.PORT, function () {
console.log("Your app is listening on port " + listener.address().port);
});