add backend

This commit is contained in:
karimik
2025-09-24 09:56:52 +02:00
parent a054741174
commit 21c35d7e41
+22
View File
@@ -0,0 +1,22 @@
const express = require('express');
const fs = require('fs');
const app = express();
const port = 3000;
app.use(express.json());
const users = JSON.parse(fs.readFileSync('users.json', 'utf8'));
app.post('/login', (req, res) => {
const { username, password } = req.body;
const user = users.find(u => u.username === username && u.password === password);
if (user) {
res.send('Login erfolgreich');
} else {
res.status(401).send('Falscher Benutzername oder Passwort');
}
});
app.listen(port, () => {
console.log(`läuft http://localhost:${port}`);
});