Skip to content

Commit

Permalink
Fixed to work with latest node version
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Willison authored and Connorhd committed Nov 19, 2009
1 parent 9a99771 commit 0a7c88a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion debug.js
@@ -1,4 +1,4 @@
var fu = require("fu.js");
var fu = require("./fu");

var debug = exports;

Expand Down
2 changes: 1 addition & 1 deletion example.js
@@ -1,3 +1,3 @@
var debug = require("debug.js");
var debug = require("./debug");

debug.listen(8080);
17 changes: 11 additions & 6 deletions fu.js
@@ -1,3 +1,8 @@
var http = require('http'),
sys = require('sys'),
posix = require('posix')
;

DEBUG = true;

var fu = exports;
Expand All @@ -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;

Expand All @@ -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(); };
Expand All @@ -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;
Expand All @@ -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);
});
}

Expand Down

0 comments on commit 0a7c88a

Please sign in to comment.