Skip to content

Instantly share code, notes, and snippets.

@pointbazaar
Last active November 28, 2018 10:58
Show Gist options
  • Select an option

  • Save pointbazaar/8a96b87d727ca06aa0af5749ae66a896 to your computer and use it in GitHub Desktop.

Select an option

Save pointbazaar/8a96b87d727ca06aa0af5749ae66a896 to your computer and use it in GitHub Desktop.

Revisions

  1. pointbazaar revised this gist Nov 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion webhook.js
    Original file line number Diff line number Diff line change
    @@ -29,5 +29,5 @@ server = http.createServer( function(req, res) {
    });

    port = 3000;
    server.listen(port, host);
    server.listen(port);
    console.log('Listening at port ' + port);
  2. pointbazaar created this gist Nov 28, 2018.
    33 changes: 33 additions & 0 deletions webhook.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    http = require('http');
    fs = require('fs');
    server = http.createServer( function(req, res) {

    console.dir(req.param);

    if (req.method == 'POST') {
    console.log("POST");
    var body = '';
    req.on('data', function (data) {
    body += data;
    console.log("Partial body: " + body);
    });
    req.on('end', function () {
    console.log("Body: " + body);
    });
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end('post received');
    }
    else
    {
    console.log("GET");
    //var html = '<html><body><form method="post" action="http://localhost:3000">Name: <input type="text" name="name" /><input type="submit" value="Submit" /></form></body>';
    var html = fs.readFileSync('index.html');
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end(html);
    }

    });

    port = 3000;
    server.listen(port, host);
    console.log('Listening at port ' + port);