Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #87 from arjansingh/patch-1

Removed 'end' event listener.
  • Loading branch information...
commit ee1cee6898ac259f7cc7d3a1f1e2d39aa77185de 2 parents 36026a3 + eeab04a
@phstc phstc authored
Showing with 9 additions and 14 deletions.
  1. +9 −14 examples/file-server.js
View
23 examples/file-server.js
@@ -3,22 +3,17 @@ 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!'} });
+var file = new static.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });
require('http').createServer(function (request, response) {
- request.addListener('end', function () {
- //
- // Serve files!
- //
- 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);
- }
- });
+ 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);
Please sign in to comment.
Something went wrong with that request. Please try again.