-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
97 lines (68 loc) · 1.8 KB
/
server.js
File metadata and controls
97 lines (68 loc) · 1.8 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// server.js
// load the things we need
var express = require('express');
var app = express();
request = require('request-json');
var client = request.createClient('https://api.mcsrvstat.us/2/yeets-retreat.ddns.net');
// set the view engine to ejs
app.set('view engine', 'ejs');
// use res.render to load up an ejs view file
// index page
var response = {
motd: { raw: [ 'big bois only' ] },
players: { online: 1, max: 40, list: [ 'No Players' ] },
mods: {
names: ['minecraft', 'modname2'],
raw: { '0': 'minecraft 1.12.2' }
}
}
app.get('/', function(req, res) {
client.get('', function(err, res, data) {
if (typeof data.mods == 'undefined') {
data.mods = {
names: ['minecraft', 'modname2'],
raw: { '0': 'minecraft 1.12.2' }}
response = data;
} else {
response = data;
}
});
var po = response.players.online
var pm = response.players.max
var mn = response.mods.names
var motd = response.motd.raw
var online = po.toString();
var max = pm.toString();
var modCount = mn.length;
res.render('pages/index', {
online: online,
max: max,
modCount: modCount,
motd: motd
});
});
// about page
app.get('/about', function(req, res) {
res.render('pages/about');
});
app.get('/details', function(req, res) {
client.get('', function(err, res, data) {
if (typeof data.mods == 'undefined') {
data.mods = {
names: ['minecraft', 'modname2'],
raw: { '0': 'minecraft 1.12.2' }}
response = data;
} else {
response = data;
}
});
var playerList = response.players.list
var modNames = response.mods.names
res.render('pages/details', {
playerList: playerList,
modNames: modNames
});
});
app.use(express.static("public"));
app.listen(8080);
console.log('8080 is the magic port');