Created
September 19, 2009 06:30
-
-
Save raycmorgan/189421 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
node.http.createServer(function (request, response) { | |
node.fs.cat("path/to/your/file.txt", "raws") | |
.addCallback(function (contents) { | |
response.sendHeader(200, {"Content-Type": "text/plain", "Content-Length": contents.length}); | |
response.sendBody(contents); | |
response.finish(); | |
}) | |
.addErrback(function () { | |
response.sendHeader(404, {"Content-Type": "text/plain"}); | |
response.sendBody("Not Found"); | |
response.finish(); | |
}); | |
}).listen(8001); | |
puts("Server running at http://127.0.0.1:8001/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment