//importovat moduly const http = require("http"); const fs = require("fs"); const path = require("path"); const server = http.createServer((req,res) => { console.log("REQ:"+req.url); const filePath = req.url === "/" ? "index.html" : req.url.slice(1) const fullPath = path.join(__dirname,filePath) console.log("oteviram:"+fullPath) fs.readFile(fullPath, (err,content) => { if(err){ res.writeHead(404, {"Content-type":"text/html"}); res.end("

ERROR

soubor nenalezen

HOME

"); // (\") eskejpování uvozovek } else { res.writeHead(200, {"Content-type":"text/html"}); res.end(content); } }) }) // const PORT = process.argv[2]; const PORT = 3000; server.listen(PORT,()=> { console.log(`Server running http://localhost:${PORT} \n Ctrl+C pro vypnutí`); })