From e58e22a329bfe012158d69d75997be406720d8a4 Mon Sep 17 00:00:00 2001 From: Craig Condon Date: Tue, 9 Apr 2013 13:52:47 -0700 Subject: [PATCH] updated example --- examples/hello-world/config.json | 1 + examples/hello-world/index.js | 8 ++++---- examples/hello-world/message.txt | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 examples/hello-world/config.json create mode 100644 examples/hello-world/message.txt diff --git a/examples/hello-world/config.json b/examples/hello-world/config.json new file mode 100644 index 0000000..f584548 --- /dev/null +++ b/examples/hello-world/config.json @@ -0,0 +1 @@ +Hello World!!! \ No newline at end of file diff --git a/examples/hello-world/index.js b/examples/hello-world/index.js index 9d4e33e..2522f97 100755 --- a/examples/hello-world/index.js +++ b/examples/hello-world/index.js @@ -1,10 +1,10 @@ var http = require("http"), +fs = require("fs"), +path = require("path"), port = 1337; -console.log(process.argv); - -console.log("started HTTP server on port %d", 1337); +console.log("started HTTP server on port %d", port = Number(process.argv.concat().pop()) || port); http.createServer(function(req, res) { - res.end("Hello World!!"); + fs.createReadStream(path.join(process.cwd(), "message.txt")).pipe(res); }).listen(port); \ No newline at end of file diff --git a/examples/hello-world/message.txt b/examples/hello-world/message.txt new file mode 100644 index 0000000..bc7774a --- /dev/null +++ b/examples/hello-world/message.txt @@ -0,0 +1 @@ +hello world! \ No newline at end of file