-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
51 lines (44 loc) · 1.24 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
/**
* Entry point for NodeJS application. Responsible for loading the (mostly static) website and handling communication with the interactive demo.
*/
var express = require('express')
var http = require('http')
var path = require('path')
//var reload = require('reload')
var bodyParser = require('body-parser')
var fetch = require('node-fetch')
const port = 8001
const app = express()
var path = require('path')
app.set('port', port)
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(bodyParser.urlencoded({ extended: true }))
// For serving static html files
app.use(express.static('public'))
app.get('/', (req, res) => {
res.set({
'Allow-access-Allow-Origin': '*'
})
// res.send("Hello World");
return res.redirect('index.html')
})
var server = http.createServer(app)
server.listen(app.get('port'), function () {
console.log('Web server listening on port ' + app.get('port'))
})
// Reload code here
/*
reload(app)
.then(function (reloadReturned) {
server.listen(app.get('port'), function () {
console.log('Web server listening on port ' + app.get('port'))
})
})
.catch(function (err) {
console.error(
'Reload could not start, could not start server/sample app',
err
)
})
*/