initial
This commit is contained in:
33
utils/peripherals/http_post_server_steelseries.js
Normal file
33
utils/peripherals/http_post_server_steelseries.js
Normal file
@@ -0,0 +1,33 @@
|
||||
http = require('http');
|
||||
fs = require('fs');
|
||||
|
||||
port = 3000;
|
||||
host = '127.0.0.1';
|
||||
|
||||
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( body );
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Handling GET request...");
|
||||
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);
|
||||
Reference in New Issue
Block a user