Создание сервера на Node JS, привязал html страницы, как привязать стили и js код?
Учусь работать с nodeJS и хочу загрузить на сервер сайт в несколько страниц. Есть 2 html документа, подключение к ним рабочее, но не понимаю как подключить файлы JS и CSS. Знаю что отправляю только html, просто не знаю как отправить остальное.
const http = require("http");
const fs = require("fs"); // модуль файловой системы
const path = require("path"); // помощь в формировании корректного пути
const PORT = 3000;
const createPath = (page) => path.resolve(__dirname, "./site/html_css", `${page}.html`);
const server = http.createServer((req, res) => {
console.log("Server request");
let basePath = "";
switch(req.url) {
case '/':
basePath = createPath('main');
break;
case '/register.html':
basePath = createPath("register");
break;
default:
res.statusCode = 404;
}
fs.readFile(basePath, (err, data) => {
if (err) {
console.log(err);
res.end();
} else {
res.end(data);
}
})
});