在跟着《node.js入门》学习的时候出现Error: Cannot find module './requestHandlers'
发布于 6个月前 作者 sulamiann 441 次浏览

server.js文件如下 var http = require(“http”); var url=require(“url”);

function start(route,handle) { function onRequest(request, response) { var pathname=url.parse(request.url).pathname;//这里的pathname是访问的url,解析出来 console.log("request for “+pathname+"received.”);

route(handle,pathname);

response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();

}

http.createServer(onRequest).listen(8888); console.log(“Server has started.”); }

function start() { console.log(“Request handler ‘start’ was called.”); }

function upload() { console.log(“Request handler ‘upload’ was called.”); }

exports.upload = upload; exports.start = start;

回到顶部