Permalink
Browse files

Fixed to work with latest node version

  • Loading branch information...
1 parent 9a99771 commit 0a7c88a70e569931d43859c72d983da267523f62 Simon Willison committed with Nov 18, 2009
Showing with 13 additions and 8 deletions.
  1. +1 −1 debug.js
  2. +1 −1 example.js
  3. +11 −6 fu.js
View
@@ -1,4 +1,4 @@
-var fu = require("fu.js");
+var fu = require("./fu");
var debug = exports;
View
@@ -1,3 +1,3 @@
-var debug = require("debug.js");
+var debug = require("./debug");
debug.listen(8080);
View
17 fu.js
@@ -1,3 +1,8 @@
+var http = require('http'),
+ sys = require('sys'),
+ posix = require('posix')
+;
+
DEBUG = true;
var fu = exports;
@@ -18,7 +23,7 @@ fu.get = function (path, handler) {
getMap[path] = handler;
};
-var server = node.http.createServer(function (req, res) {
+var server = http.createServer(function (req, res) {
if (req.method === "GET" || req.method === "HEAD") {
var handler = getMap[req.uri.path] || notFound;
@@ -45,7 +50,7 @@ var server = node.http.createServer(function (req, res) {
fu.listen = function (port, host) {
server.listen(port, host);
- puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/");
+ sys.puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/");
};
fu.close = function () { server.close(); };
@@ -66,8 +71,8 @@ fu.staticHandler = function (filename) {
return;
}
- puts("loading " + filename + "...");
- var promise = node.fs.cat(filename, encoding);
+ sys.puts("loading " + filename + "...");
+ var promise = posix.cat(filename, encoding);
promise.addCallback(function (data) {
body = data;
@@ -77,12 +82,12 @@ fu.staticHandler = function (filename) {
if (!DEBUG)
headers.push(["Cache-Control", "public"]);
- puts("static file " + filename + " loaded");
+ sys.puts("static file " + filename + " loaded");
callback();
});
promise.addErrback(function () {
- puts("Error loading " + filename);
+ sys.puts("Error loading " + filename);
});
}

0 comments on commit 0a7c88a

Please sign in to comment.