Created
July 23, 2014 21:37
-
-
Save shirhatti/d60ac0e0244883c20882 to your computer and use it in GitHub Desktop.
dummyserver
This file contains 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
var http = require('http'); | |
test_data = [ | |
["test_1", "test_1_data"], | |
["test_2", "test_2_data"], | |
["test_3", "test_3_data"] | |
] | |
http.createServer(function (req, res) { | |
switch(req.url) { | |
case '/complete': | |
if (req.method == 'POST') { | |
console.log("[501] " + req.method + " to " + req.url); | |
res.writeHead(501, "Not implemented", {'Content-Type': 'application/json'}); | |
res.write(JSON.stringify(test_data)); | |
res.end(); | |
break; | |
} | |
else { | |
res.writeHead(404, "Not found", {'Content-Type': 'text/html'}); | |
res.end(); | |
console.log("[404] " + req.method + " to " + req.url); | |
} | |
default: | |
res.writeHead(404, "Not found", {'Content-Type': 'text/html'}); | |
res.end(); | |
console.log("[404] " + req.method + " to " + req.url); | |
}; | |
}).listen(5000, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:5000/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment