-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
53 lines (41 loc) · 1.37 KB
/
server.js
File metadata and controls
53 lines (41 loc) · 1.37 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
var express = require('express')
var exphbs = require('express-handlebars')
const bodyParser = require('body-parser');
var port = process.env. PORT || 8000;
var app = express()
app.engine('handlebars', exphbs.engine({
defaultLayout: 'main'
}))
app.set('view engine', 'handlebars')
app.use(express.static('public'))
app.get('/', function(req, res, next) {
res.status(200).render('mainPage')
})
// https://stackoverflow.com/questions/26079611/node-js-typeerror-path-must-be-absolute-or-specify-root-to-res-sendfile-failed
app.get('/modules/ui_interactions', function(req, res, next) {
res.status(200).sendFile(__dirname + '\\public\\modules\\ui_interactions.js')
})
app.get('/modules/ui_inputs', function(req, res, next) {
res.status(200).sendFile(__dirname + '\\public\\modules\\ui_inputs.js')
})
app.get('/modules/visualizer', function(req, res, next) {
res.status(200).sendFile(__dirname + '\\public\\modules\\visualizer.js')
})
// app.post('/new', function (req, res, next) {
// if (req.body && req.body.name && req.body.stats) {
// next()
// } else {
// res.status(400)
// }
// }, function (req, res, next) {
// var newEntry = {
// name: req.body.name,
// stats: req.body.stats
// }
// })
app.listen(port, function(err) {
if (err) {
throw err
}
console.log('== Server listening on port', port)
})