forked from f4irline/csgo-artnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayloads.js
36 lines (29 loc) · 971 Bytes
/
payloads.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
/**
* The purpose of this module is to test that the payloads are coming
* in from the CS:GO client as they should.
*/
http = require('http');
fs = require('fs');
const HOST = 'localhost';
const PORT = 3000;
server = http.createServer( function(req, res) {
if (req.method == 'POST') {
console.log("Handling POST request...");
res.writeHead(200, {'Content-Type': 'text/html'});
var body = '';
req.on('data', function (data) {
body += data;
});
req.on('end', function () {
console.log("POST payload: " + body);
res.end( '' );
});
} else {
console.log("Not expecting other request types...");
res.writeHead(200, {'Content-Type': 'text/html'});
var html = '<html><body>HTTP Server at http://' + HOST + ':' + PORT + '</body></html>';
res.end(html);
}
});
server.listen(PORT, HOST);
console.log('Listening at http://' + HOST + ':' + PORT);