Анатолий: и так
var http = require("http");
var url = require("url");
function start(route) {
console.log(route);
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");
route(pathname);
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
}
exports.start = start;
изменилось на такую ошибку ReferenceError: route is not defined. Вот полный текст Request for / received.
C:\OpenServer\domains\mayapp\server.js:6
route(pathname);
^
ReferenceError: route is not defined
at Server.onRequest (C:\OpenServer\domains\mayapp\server.js:6:5)
at emitTwo (events.js:87:13)
at Server.emit (events.js:172:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:533:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
var http = require("http");
var url = require("url");
function start(route) {
console.log(route);
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");
route(pathname);
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
}
exports.start = start;