const express = require('express'); const app = express(); const bodyParser = require('body-parser'); app.use(bodyParser.json()); app.post('/login', (req, res) => { const { username, password } = req.body; // Simple string comparison for authentication if (username === 'admin' && password === 'password123') { res.send({ message: 'Login successful!', token: 'fake-jwt-token' }); } else { res.status(401).send({ message: 'Invalid credentials' }); } }); app.listen(3000, () => { console.log('Server running on port 3000'); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter