forked from JalinWu/Clickjacking-playground-S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (39 loc) · 1.3 KB
/
index.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
var express = require('express');
var bodyParser = require('body-parser');
// ========== start A_website ==========
var app = express();
const addSecurityHeaders = function(req, res, next) {
// http response header 設定於此
next();
}
// 所有的請求都會經過這個 middleware
app.use(addSecurityHeaders)
// 解析application/json
app.use(bodyParser.json());
// 解析application/x-www-form-urlencoded,從網頁表單送來的資料
app.use(bodyParser.urlencoded({extended: true}));
// EJS
app.set('view engine', 'ejs');
app.set('views', './A_website/views');
// app.use(express.static(__dirname + '/A_website/public'));
// Routes
app.use('/', require('./A_website/routes/index.js'));
const PORT = 3001;
app.listen(PORT, function() {
console.log(`A_website listening on port ${PORT}!`);
});
// ========== start X_website ==========
var app2 = express();
// 解析application/json
app2.use(bodyParser.json());
// 解析application/x-www-form-urlencoded,從網頁表單送來的資料
app2.use(bodyParser.urlencoded({extended: true}));
// EJS
app2.set('view engine', 'ejs');
app2.set('views', './X_website/views');
// Routes
app2.use('/', require('./X_website/routes/index.js'));
const PORT2 = 9999;
app2.listen(PORT2, function() {
console.log(`X_website listening on port ${PORT2}!`);
});