khinester
unread,Oct 7, 2010, 8:36:41 AM10/7/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PeepCode
here is a diff for my previous post, which i guess is still in
approval:
$ git diff server.js
diff --git a/server.js b/server.js
index 5c004e0..e367295 100644
--- a/server.js
+++ b/server.js
@@ -1,13 +1,13 @@
+require.paths.unshift(__dirname + "/vendor");
+
var http = require('http'),
- sys = require('sys');
+ sys = require('sys'),
+ nodeStatic = require('node-static/lib/node-static');
+var file = new(nodeStatic.Server)('./public', {cache: false});
var server = http.createServer(function(request, response) {
request.addListener('end', function() {
- response.writeHead(200, {
- 'Content-Type': 'text/plain'
- });
- response.write(sys.inspect(request));
- response.end();
- };)
+ file.serve(request, response);
+ })
})
-server.listen(8000);
\ No newline at end of file
also you will need to patch the node-static code
$ git diff lib/node-static.js
diff --git a/lib/node-static.js b/lib/node-static.js
index 1367c77..4639591 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -236,7 +236,7 @@ this.Server.prototype.stream = function (pathname,
files, buffer, res, callback)
mode: 0666,
bufferSize: 4096
}).addListener('data', function (chunk) {
- chunk.copy (buffer, offset, 0);
+ buffer.write(chunk, offset, 'binary');
res.write (chunk, 'binary');
offset += chunk.length;
}).addListener('close', function () {