view node_modules/node-static/examples/file-server.js @ 72:9af4250ff7d5

added file to test why static webserver doesnt work on home machine - using connect now instead of node-static this will be pushed into the main nodescore.js once its cleaned up
author tzara <rc-web@kiben.net>
date Sun, 27 Oct 2013 01:49:58 +0100
parents 333afcfd3f3a
children
line wrap: on
line source
var static = require('../lib/node-static');

//
// Create a node-static server to serve the current directory
//
var file = new static.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });

require('http').createServer(function (request, response) {
    file.serve(request, response, function (err, res) {
        if (err) { // An error as occured
            console.error("> Error serving " + request.url + " - " + err.message);
            response.writeHead(err.status, err.headers);
            response.end();
        } else { // The file was served successfully
            console.log("> " + request.url + " - " + res.message);
        }
    });
}).listen(8080);

console.log("> node-static is listening on http://127.0.0.1:8080");