HTML and CSS Reference
In-Depth Information
work with the code in the topic can be downloaded from the topic's website. 3 Place
it in chapp's deps directory.
Listing 15.38 loads the module in chapp's lib/server.js . It's set up to
serve files from the public directory, e.g., http://localhost:8000/index.html will
attempt to serve public/index.html .
Listing 15.38 Adding static file serving to chapp's server
/* ... */
var paperboy = require("node-paperboy");
module.exports = http.createServer(function (req, res) {
if (url.parse(req.url).pathname == "/comet") {
/* ... */
} else {
var delivery = paperboy.deliver("public", req, res);
delivery.otherwise(function () {
res.writeHead(404, { "Content-Type": "text/html" });
res.write("<h1>Nothing to see here, move along</h1>");
res.close();
});
}
});
The otherwise callback is triggered if no file is found in public matching
the requested URL. In that case we serve up a really tiny 404 page. To serve up the
chat client, create public/js , and copy over the following files:
tdd.js
observable.js
function.js
object.js
user form controller.js
Save Listing 15.39 in public/index.html .
Listing 15.39 The client HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
3. http://tddjs.com
 
Search WWH ::




Custom Search