-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·50 lines (40 loc) · 1.52 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
var express = require('express');
var app = express();
app.use(function(req, res, next) {
if (req.headers.origin) {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Headers', 'X-Requested-With,Content-Type,Authorization')
res.header('Access-Control-Allow-Methods', 'GET,PUT,PATCH,POST,DELETE')
if (req.method === 'OPTIONS') return res.send(200)
}
next()
})
var morgan = require('morgan');
// set morgan to log info about our requests for development use.
app.use(morgan('dev'));
var fs = require('fs');
app.get('/', function(req,res){
//res.send("hi");
res.redirect('/quiz-vue/index.html')
});
app.use(express.static('public'));
var loginSystem = require('./login/login_server.js');
var login = loginSystem.router;
loginSystem.settings.MAIN_PAGE = "/";
loginSystem.setup(app);
app.use('/login_system', login);
var userQuestionSystem = require('./user_data/userDataRouter.js');
userQuestionSystem.settings.isLoggedIn = loginSystem.isLoggedIn;
app.use('/user_data', userQuestionSystem.router);
///////////////////////////////////////////////////////////////////////////////////////
app.get('/login', function(req,res){
res.redirect('/login_system/login');
});
app.get('/session', function(req,res){
res.send(JSON.stringify(req.session.id));
});
app.get('/user_data', function(req,res){
res.sendFile('./user_data/user_data.html', {root: __dirname });
});
const port = process.env.PORT || 8080;
app.listen(port,() => console.log(`Listening on ${ port }`));