Router Load đường dẫn Router gõ web var http = require('http'); http.createServer(function(req,res){ console.log(req.url); }).listen(1234); var load_router = function(req,res){ console.log(req.url); } module.exports.load_router = load_router ; Cách app.js Cách 2: viết theo module var http = require('http'); var app = require('./app.js'); http.createServer(app.load_router).listen(3000); Xử lý Router khác var fs = require('fs'); function docFileHtml(tenfile,res){ res.writeHead(200,{"Content-type":"text/html; charset=utf-8"}); fs.ReadStream(tenfile).pipe(res); } var load_router = function(req,res){ var path = req.url; switch (path) { case "/": docFileHtml('giaodien1.html',res); break; case "/tin-tuc": docFileHtml('giaodien2.html',res); break; default: docFileHtml('404.html',res); break ; } } module.exports.load_router = load_router ; ...Xử lý Router khác var fs = require('fs'); function docFileHtml(tenfile,res){ res.writeHead(200,{"Content-type":"text/html; charset=utf-8"}); fs.ReadStream(tenfile).pipe(res); } var load _router. .. docFileHtml('giaodien2.html',res); break; default: docFileHtml('404.html',res); break ; } } module. exports.load _router = load _router ; ... res.writeHead(200,{"Content-type":"text/html; charset=utf-8"}); fs.ReadStream(tenfile).pipe(res); } var load _router = function(req,res){ var path = req.url; switch (path) { case "/": docFileHtml('giaodien1.html',res); break; case "/tin-tuc":