[Pkg-javascript-commits] [node-static] 06/151: (doc) update example
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:17:55 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository node-static.
commit 4f1c974b4c1272ea65315e6bceff4d08725b4e85
Author: cloudhead <self at cloudhead.net>
Date: Tue Jul 27 14:58:15 2010 -0400
(doc) update example
---
examples/file-server.js | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/examples/file-server.js b/examples/file-server.js
index a30a79f..a12c43b 100644
--- a/examples/file-server.js
+++ b/examples/file-server.js
@@ -2,19 +2,23 @@ var sys = require('sys');
var static = require('../lib/node-static');
//
-// Create a node-static server instance to serve the './public' folder
+// Create a node-static server to serve the current directory
//
-var file = new(static.Server)();
+var file = new(static.Server)('.', { cache: 7200, headers: {'X-Hello':'World!'} });
require('http').createServer(function (request, response) {
request.addListener('end', function () {
//
// Serve files!
//
- file.serve(request, response, function (status, headers) {
- sys.error("> Error serving " + request.url + " - " + status);
- response.writeHead(status, headers);
- response.end();
+ file.serve(request, response, function (err, res) {
+ if (err) { // An error as occured
+ sys.error("> Error serving " + request.url + " - " + err.message);
+ response.writeHead(err.status, err.headers);
+ response.end();
+ } else { // The file was served successfully
+ sys.puts("> " + request.url + " - " + res.message);
+ }
});
});
}).listen(8080);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git
More information about the Pkg-javascript-commits
mailing list