Created
August 19, 2013 20:24
-
-
Save akuhn/6273651 to your computer and use it in GitHub Desktop.
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
var http = require('http'); | |
var shared = {count: 0} | |
var server = http.createServer(function (req, res) { | |
console.log([req.method,req.url]) | |
res.writeHead(200, {'Content-Type': 'text/plain'}) | |
res.write('You called me ' + (shared.count += 1) + ' times!\n') | |
res.write('You are looking at ' + req.url + '\n') | |
res.end() | |
}) | |
server.listen(1337, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:1337/'); | |
// node server.js | |
// curl -X GET http://127.0.0.1:1337 | |
// curl -X POST http://127.0.0.1:1337 -d '{"text":"Hello worlds!"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment