// 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) => { const filePath = req.url === "/" ? "index.html" : req.url.slice(1); const fullPath = path.join(__dirname,filePath) fs.readFile(fullPath, (err, content) => { if(err) { res.writeHead(404, {"Content-Type":"text/html"}) res.end("

404 not Found

"); } else { res.writeHead(200, {"Content-Type":"text/html"}) res.end(content); } }) }) const PORT = 3000; //spuštění serveru server.listen(PORT, () => { console.log(`Server běží na http://localhost:${PORT}`); })