Last active
November 28, 2018 10:58
-
-
Save pointbazaar/8a96b87d727ca06aa0af5749ae66a896 to your computer and use it in GitHub Desktop.
salesforce webhooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
console.log('Listening at port ' + port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment