4
1
Fork 0
This repository has been archived on 2019-02-05. You can view files and clone it, but cannot push or open issues or pull requests.
Shakes_and_Fidget/index.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

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-19 23:44:10 +00:00
data.push(el[Object.keys(el)])
2018-02-19 22:59:28 +00:00
});
// Use fetched Data
data.forEach(el => {
2018-02-19 23:44:10 +00:00
console.log(el.class)
})
2018-02-20 00:07:10 +00:00
res.render('index', {
instances: [
{
name: 'Test',
level: 1000
},
{
name: 'Tes2t',
level: 10200
}
]
})
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)