node-static的'当前目录'在哪里?

时间:2013-06-23 19:41:21

标签: node.js

这是我的服务器代码,实际上是节点静态示例代码!

var static = require('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");

所以当它说“当前目录”时,它意味着什么?

0 个答案:

没有答案