http = require('http');
fs = require('fs');
path = require('path');
http.createServer(function (request, response) {
const filePath = path.join(__dirname, 'index.html');
// HTML-Datei lesen
fs.readFile(filePath, function(err, content) {
if (err) {
response.writeHead(500, { 'Content-Type': 'text/plain' });
response.end('Ein Fehler ist aufgetreten: ' + err.message);
} else {
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end(content, 'utf-8');
}
});
}).listen(8080);
console.log('Der Server läuft auf: http://localhost:8080/');