mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Set up new module structure
This commit is contained in:
parent
5f5178d2e8
commit
2e864f5293
534 changed files with 235854 additions and 1 deletions
25
node_modules/node-static/examples/file-server.js
generated
vendored
Normal file
25
node_modules/node-static/examples/file-server.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).listen(8080);
|
||||
|
||||
console.log("> node-static is listening on http://127.0.0.1:8080");
|
||||
Loading…
Add table
Add a link
Reference in a new issue