42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
var app = require('express')()
|
|
var http = require('http').Server(app)
|
|
var request = require('request')
|
|
var exphbs = require('express-handlebars')
|
|
|
|
app.engine('.hbs', exphbs({defaultLayout: 'single', extname: '.hbs'}))
|
|
app.set('view engine', '.hbs')
|
|
|
|
var url = 'http://192.168.178.109:1024/'
|
|
|
|
// Host the HTML File
|
|
app.get('/', function(req, res){
|
|
request({
|
|
url: url,
|
|
json: true,
|
|
auth: {
|
|
user: 'Simon',
|
|
pass: 'password'
|
|
}
|
|
}, function(error, response, body){
|
|
var data = []
|
|
if (!error && response.statusCode === 200) {
|
|
body.response.bot.accounts.forEach(el => {
|
|
var tmp = el[Object.keys(el)]
|
|
tmp.logs = ""
|
|
tmp.settings = ""
|
|
tmp.exp_percentage = tmp.experience/tmp.experienceForNextLevel
|
|
data.push(tmp)
|
|
});
|
|
|
|
res.render('index', {
|
|
instances: data
|
|
})
|
|
} else console.error('HTTP ERROR ' + response.statusCode + '')
|
|
});
|
|
})
|
|
|
|
app.get('/assets/*', function(req, res){
|
|
res.sendFile(__dirname + req.originalUrl)
|
|
})
|
|
|
|
app.listen(8080)
|