Files
linkedin-text-formatter/server.js
Joachim Hummel 1f5e6b1f60 Fix: Route-Handler vor static middleware registrieren
express.static hat / abgefangen und index.html direkt geliefert,
bevor der Route-Handler die Platzhalter {{NAME}}/{{SLOGAN}}/{{INITIALS}}
ersetzen konnte.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 10:12:21 +00:00

29 lines
873 B
JavaScript

'use strict';
require('dotenv').config();
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 3000;
const NAME = process.env.NAME || 'Name';
const SLOGAN = process.env.SLOGAN || '';
const INITIALS = NAME.split(' ').map(w => w[0]).join('').slice(0, 2).toUpperCase();
app.get('/', (req, res) => {
let html = fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8');
html = html
.replace('{{INITIALS}}', INITIALS)
.replace('{{NAME}}', NAME)
.replace('{{SLOGAN}}', SLOGAN);
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.send(html);
});
app.use(express.static(path.join(__dirname, 'public')));
app.listen(PORT, () => {
console.log(`LinkedIn Formatter läuft auf http://localhost:${PORT}`);
});