forked from Databaseprogramming-Sunshine/Sunshine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
89 lines (78 loc) ยท 3.05 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
89
var express = require("express");
var session = require("express-session");
var app = express();
var router = express.Router();
var bodyParser = require("body-parser");
var cookieParser = require("cookie-parser");
var path = require("path");
var ejs = require("ejs");
var login = require("./routes/login");
var join = require("./routes/join");
var logout = require("./routes/logout");
var staff_attendance = require("./routes/staff_attendance");
var staff_attendancelist = require("./routes/staff_attendancelist");
var staff_lecturelist = require("./routes/staff_lecturelist");
var staff_main = require("./routes/staff_main");
var student_attendance_error = require("./routes/student_attendance_error");
var student_attendance_suc = require("./routes/student_attendance_suc");
var student_attendance = require("./routes/student_attendance");
var student_main = require("./routes/student_main");
var student_my = require("./routes/student_my");
var email = require("./email");
var staff_att_start = require("./routes/staff_att_start");
var staff_studentlist = require("./routes/staff_studentlist");
var staff_att_start = require("./routes/staff_att_start");
var user_session = require("./user.session");
app.use(express.static(__dirname + "/public"));
app.set("view engine", "ejs"); //'ejs'ํฌํ๋ฆฟ์ ์์ง์ผ๋ก ํ๋ค.
app.set("views", path.join(__dirname, "views")); //ํด๋, ํด๋๊ฒฝ๋ก ์ง์
app.engine("html", require("ejs").renderFile);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use( //์ธ์
์ค์
session({
secret: "keyboard cat",
resave: false,
saveUninitialized: true,
cookie: { secure: true },
store: user_session,
cookie: {
maxAge: 24000 * 60 * 60, // ์ฟ ํค ์ ํจ๊ธฐ๊ฐ 24์๊ฐ
},
})
);
app.get("/", (req, res) => {
console.log("๋ฉ์ธํ์ด์ง ์๋");
if (req.session.isStudent == true) {
if (req.session.isLogined == true) {
res.redirect("/student_main");
} else {
res.redirect("/login");
}
} else {
if (req.session.isLogined == true) {
res.redirect("staff_main");
} else {
res.redirect("login");
}
}
});
app.use("/", login);
app.use("/join", join);
app.use("/login", login);
app.use("/logout", logout);
app.use("/staff_attendance", staff_attendance);
app.use("/staff_attendancelist", staff_attendancelist);
app.use("/staff_lecturelist", staff_lecturelist);
app.use("/staff_main", staff_main);
app.use("/staff_studentlist", staff_studentlist);
app.use("/student_attendance_error", student_attendance_error);
app.use("/student_attendance_suc", student_attendance_suc);
app.use("/student_attendance", student_attendance);
app.use("/student_main", student_main); //ejsํ์ผ์์ <a href="/student_main">์ด๋ฐ์์ผ๋ก ๋งํฌ ์ค์ ํด์ฃผ๋ฉด ๋ผ์ฐํฐ ๋ชจ๋์์ student_main์ด ๋ถ๋ฌ์์ง->๋ผ์ฐํฐ ๋ชจ๋์์ student_main์ ejsํ์ผ์ ๋ ๋๋งํด์ค
app.use("/student_my", student_my);
app.use("/staff_att_start", staff_att_start);
email.surveyEmail(); //์ด๋ฉ์ผ ๋ณด๋ด๊ธฐ ํจ์
app.listen("80");
module.exports = app;