2018-02-19 23:44:10 +00:00
|
|
|
var app = require('express')()
|
|
|
|
var http = require('http').Server(app)
|
|
|
|
var request = require('request')
|
|
|
|
var exphbs = require('express-handlebars')
|
2018-02-19 22:59:28 +00:00
|
|
|
|
2018-02-19 23:44:10 +00:00
|
|
|
app.engine('.hbs', exphbs({defaultLayout: 'single', extname: '.hbs'}))
|
|
|
|
app.set('view engine', '.hbs')
|
2018-02-19 22:59:28 +00:00
|
|
|
|
2018-02-19 23:44:10 +00:00
|
|
|
|
|
|
|
var url = 'http://192.168.178.109:1024/'
|
2018-02-19 22:59:28 +00:00
|
|
|
|
|
|
|
// Host the HTML File
|
|
|
|
app.get('/', function(req, res){
|
2018-02-19 23:49:09 +00:00
|
|
|
//name, class, experience, gold, level
|
2018-02-19 22:59:28 +00:00
|
|
|
request({
|
|
|
|
url: url,
|
|
|
|
json: true,
|
|
|
|
auth: {
|
|
|
|
user: 'Simon',
|
|
|
|
pass: 'password'
|
|
|
|
}
|
|
|
|
}, function(error, response, body){
|
2018-02-19 23:44:10 +00:00
|
|
|
var data = []
|
2018-02-19 22:59:28 +00:00
|
|
|
if (!error && response.statusCode === 200) {
|
|
|
|
body.response.bot.accounts.forEach(el => {
|
2018-02-20 00:33:22 +00:00
|
|
|
var tmp = el[Object.keys(el)]
|
|
|
|
tmp.logs = ""
|
|
|
|
tmp.settings = ""
|
|
|
|
data.push(tmp)
|
2018-02-19 22:59:28 +00:00
|
|
|
});
|
|
|
|
|
2018-02-20 00:07:10 +00:00
|
|
|
res.render('index', {
|
2018-02-20 00:33:22 +00:00
|
|
|
instances: data
|
2018-02-20 00:07:10 +00:00
|
|
|
})
|
2018-02-19 23:44:10 +00:00
|
|
|
} else console.error('HTTP ERROR ' + response.statusCode + '')
|
2018-02-19 22:59:28 +00:00
|
|
|
});
|
|
|
|
})
|
2018-02-19 23:44:10 +00:00
|
|
|
|
|
|
|
app.get('/assets/*', function(req, res){
|
|
|
|
res.sendFile(__dirname + req.originalUrl)
|
|
|
|
})
|
|
|
|
|
2018-02-19 23:49:09 +00:00
|
|
|
app.listen(8080)
|