Created
September 13, 2012 22:47
-
-
Save stevenklise/3718300 to your computer and use it in GitHub Desktop.
Simple static file serving with Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "node-static-test", | |
"version": "0.0.1", | |
"engines": { | |
"node": "0.8.x" | |
}, | |
"dependencies" : { | |
"http": "latest", | |
"node-static": "latest" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// download these files | |
// If you're running node 0.8.x, run `$ npm install` | |
// Then `$ node server.js` | |
var http = require('http'); | |
var static = require('node-static'); | |
http.createServer(function(request,response) { | |
var file = new static.Server('./public', { | |
cache: false | |
}); | |
request.addListener('end', function() { | |
file.serve(request, response); | |
}); | |
}).listen(1337,'0.0.0.0'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment