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>");
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:
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"
Search WWH ::

Custom Search