====== LU03.L02 ====== **app.js** // Author: Volkan Demir, 07.05.2026 // Erster kleiner Express-Server in JavaScript // Dieser Server liest die index.html Datei und sendet sie an den Browser, wenn die Startseite ("/") aufgerufen wird. const http = require("http"); const fs = require("fs"); const PORT = 3001; const server = http.createServer(function(req, res) { res.writeHead(200, { "Content-Type": "text/html" }); //res.write(" Hallo Welt! "); //res.end(); fs.readFile("index.html", function (err, data) { if (err) { res.writeHead(404, { "Content-Type": "text/html" }); res.write("Datei nicht gefunden"); return; } else { res.write("

Welt! Hier ist die index.html Datei von Demir:

"); // Teilauftrag 1 res.write('

ich will hier raus!!!

'); // Teilauftrag 2 // Anlegen und Anzeigen einer kleine Tabelle mittels JS-generierten HTML-Code htmlstr = ''; // beginning of the table htmlstr += ''; // Header of the table htmlstr += ''; // Header of the table htmlstr += '
#NameSurenameAge
1DemirVolkan57
'; // End of the table res.write(htmlstr); } res.end(); }); }); server.listen(PORT, function() { console.log("Server läuft auf Port " + PORT); }); **index.html** Node.js Server Nachricht

Antwort vom Server:

{SERVER_MSG}}<

---- [[https://creativecommons.org/licenses/by-nc-sa/4.0/|{{https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png}}]] Volkan Demir