// načtení knihoven const http = require("http"); const fs = require("fs"); const path = require("path"); //vytvoření chování serveru const server = http.createServer((req,res) => { //přečti url const filePath = req.url === "/" ? "pages/index.html" : `pages${req.url}.html`; //načti hledaný soubor fs.readFile(path.join(__dirname,filePath),"utf8", (err,data) => { if (req.url == "/youtube") { res.writeHead(302, {"Location":"https://www.youtube.com"}); res.end(); } if (err) { //když se nenalezne soubor res.writeHead(404, {"Content-Type" : "text/html"}); res.end("