-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
111 lines (80 loc) · 2.73 KB
/
Copy pathindex.js
File metadata and controls
111 lines (80 loc) · 2.73 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// https://expressjs.com/en/guide/routing.html
// REQUIRES
const express = require("express");
const app = express();
app.use(express.json());
const fs = require("fs");
// mapping the file system paths to the app's virtual paths
app.use("/js", express.static("./public/js"));
app.use("/css", express.static("./public/css"));
app.use("/img", express.static("./public/img"));
// get the root node
app.get("/", function (req, res) {
let doc = fs.readFileSync("./app/html/index.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/about", function (req, res) {
let doc = fs.readFileSync("./app/html/about.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/nav_before_login", function (req, res) {
let doc = fs.readFileSync("./app/html/text/nav_before_login.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/footer_before_login", function (req, res) {
let doc = fs.readFileSync("./app/html/text/footer_before_login.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/nav_after_login", function (req, res) {
let doc = fs.readFileSync("./app/html/text/nav_after_login.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/footer_after_login", function (req, res) {
let doc = fs.readFileSync("./app/html/text/footer_after_login.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/login", function (req, res) {
let doc = fs.readFileSync("./app/html/login.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/calendar", function (req, res) {
let doc = fs.readFileSync("./app/html/calendar.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/task_list", function (req, res) {
let doc = fs.readFileSync("./app/html/task_list.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/course_list", function (req, res) {
let doc = fs.readFileSync("./app/html/course_list.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/profile", function (req, res) {
let doc = fs.readFileSync("./app/html/profile.html", "utf8");
// sending the text stream
res.send(doc);
});
app.get("/course_grade", function (req, res) {
let doc = fs.readFileSync("./app/html/course_grade.html", "utf8");
// sending the text stream
res.send(doc);
});
// for the page not found (i.e. 404)
app.use(function (req, res, next) {
res.status(404).send("<html><head><title>Page not found!</title></head><body><p>ERROR 404 Page not found</p></body></html>");
})
// run server
let port = 8000;
app.listen(port, function () {
console.log("App is listening in port " + port);
})