-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
88 lines (65 loc) · 1.75 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
if (process.env.NODE_ENV !== "production") {
require('dotenv').config();
}
const path = require("path");
const express = require("express");
const port = process.env.PORT;
const app = express();
const favicon = require('serve-favicon');
app.set("view engine", "ejs");
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "public")));
// middleware for serving favicon
app.use(favicon(path.join(__dirname, "public", "img", "favicon.ico")));
app.listen(port, () => {
console.log(`Listening on port ${port}`);
})
app.get("/", (req, res) => {
res.redirect("/home");
})
app.get("/home", (req, res) => {
res.render("home", {
currentPage: req.originalUrl
});
})
app.get("/articles", (req, res) => {
res.render("articles", {
currentPage: req.originalUrl
});
})
// Decide if we want to use slugs? or a router function?
app.get("/articles/linear_regression", (req, res) => {
res.render("pages/linear_regression", {
currentPage: req.originalUrl
});
})
app.get("/articles/feature_engineering", (req, res) => {
res.render("pages/feature_engineering", {
currentPage: req.originalUrl
});
})
app.get("/projects", (req, res) => {
res.render("projects", {
currentPage: req.originalUrl
});
})
app.get("/professional", (req, res) => {
res.render("professional", {
currentPage: req.originalUrl
});
})
app.get("/personal", (req, res) => {
res.render("personal", {
currentPage: req.originalUrl
});
})
app.get("/videos", (req, res) => {
res.render("videos", {
currentPage: req.originalUrl
});
})
app.get("/sitemap", (req, res) => {
res.render("sitemap", {
currentPage: req.originalUrl
});
})