Path: blob/master/node_modules/node-static/examples/file-server.js
334 views
var static = require('../lib/node-static');12//3// Create a node-static server to serve the current directory4//5var file = new static.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });67require('http').createServer(function (request, response) {8file.serve(request, response, function (err, res) {9if (err) { // An error as occured10console.error("> Error serving " + request.url + " - " + err.message);11response.writeHead(err.status, err.headers);12response.end();13} else { // The file was served successfully14console.log("> " + request.url + " - " + res.message);15}16});17}).listen(8080);1819console.log("> node-static is listening on http://127.0.0.1:8080");202122