Last active
November 28, 2018 10:58
-
-
Save pointbazaar/8a96b87d727ca06aa0af5749ae66a896 to your computer and use it in GitHub Desktop.
Revisions
-
pointbazaar revised this gist
Nov 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,5 +29,5 @@ server = http.createServer( function(req, res) { }); port = 3000; server.listen(port); console.log('Listening at port ' + port); -
pointbazaar created this gist
Nov 28, 2018 .There are no files selected for viewing
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 charactersOriginal 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);