const express = require('express'); const app = express(); const port = 8081; app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(express.static('static')); app.post('/login', (req, res) => { const { username, password } = req.body; // 模拟登录验证 if (username === '123' && password === '123') { // res.redirect(302, '/success.html'); res.json({ success: true, redirectUrl: '/success.html' }); } else { res.status(401).json({ success: false, message: 'Invalid credentials' }); } }); // catch 404 and forward to error handler app.use(function(req, res, next) { res.status(404); res.end('