const http = require("http"); const fs =require("fs"); const path = require("path"); const server = http.createServer((req,res) =>{ const filePath = req.url === "/" ? "index.html" : req.url.slice(1); const fullPath = path.join(__dirname,filePath) console.log("Open: "+fullPath) fs.readFile(fullPath,(err,content) => { if(err){ res.writeHead(404, {"content-type":"text/html"}); //vlastní 404 error zpráva res.end("

Jejda, je to rozbite
aneb
404

HOME") // (\") takzvaný eskejpování pro ignorování uvozovek v textu ohraničený stejnými uvozovkami } else { res.writeHead(200, {"Content-type":"text/html"}); res.end(content); } }) }); const PORT = 3000; server.listen(PORT, () => { console.log(`Server running at http://localhost:${PORT}/ \n Ctrl+C pro vypnuti`) }); //node index.js