-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpos-express.js
38 lines (30 loc) · 1.3 KB
/
mpos-express.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
const express = require('express')
const app = express()
const path = require('path')
const PORT = process.env.PORT || 8080
const os = require('os')
const networkInterfaces = os.networkInterfaces()
// enable express.js to parse json data
const bodyParser = require('body-parser')
app.use(bodyParser.json())
// serve static front-end resources
app.use(express.static('gui'));
app.use('/data', require('./api-express/actions'))
app.use('/gui', require('./routes/gui-express'))
app.get('*', (req, res) => {
res.redirect('/gui/menu')
});
app.listen(PORT, () => {
console.log(`Express server started on port ${PORT}`)
})
if (typeof networkInterfaces.wlp2s0 !== 'undefined') {
console.log(`\n(a) app-server-ip: ${networkInterfaces.wlp2s0[0].address}:${PORT}/gui/menu\n`)
} else if (typeof networkInterfaces.enp3s0f1 !== 'undefined') {
console.log(`\n(b) app-server-ip: ${networkInterfaces.enp3s0f1[0].address}:${PORT}/gui/menu\n`)
} else if (typeof networkInterfaces['Wi-Fi'] !== 'undefined') {
console.log(`\n(c) app-server-ip: ${networkInterfaces['Wi-Fi'][1].address}:${PORT}/gui/menu\n`)
} else if (typeof networkInterfaces.Ethernet !== 'undefined') {
console.log(`\n(d) app-server-ip: ${networkInterfaces.Ethernet[1].address}:${PORT}/gui/menu\n`)
} else {
console.log('\nno IP found for sharing over the network')
}