-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (33 loc) · 1.07 KB
/
app.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
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const app = express();
app.use(express.static(path.join(__dirname, 'public')));
app.use(cookieParser());
// EJS 설정
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// 기본 라우트
app.get('/', (req, res) => {
let lang = req.cookies.language || 'kor';
res.render('pages/home', { lang });
});
// 기본 라우트
app.get('/Professor', (req, res) => {
let lang = req.cookies.language || 'kor';
res.render('pages/Professor', { lang });
});
app.get('/Research', (req, res) => {
let lang = req.cookies.language || 'kor';
res.render('pages/Research', { lang });
});
// 언어 변경 라우트
app.get('/setLanguage/:lang', (req, res) => {
const { lang } = req.params;
res.cookie('language', lang, { maxAge: 30 * 24 * 60 * 60 * 1000, httpOnly: true });
res.redirect('back');
});
const PORT = process.env.PORT || 9000;
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});