Express.js 路由:动态颜色标题网页
var express = require('express'); var router = express.Router();
var colors = ['red', 'yellow', 'green', 'blue'];
var currentColorIndex = 0;
router.get('/color.html', function(req, res) { var currentColor = colors[currentColorIndex]; var html = '
' + currentColor + '
'; res.send(html);currentColorIndex++; if(currentColorIndex >= colors.length) { currentColorIndex = 0; } });
module.exports = router;
原文地址: https://www.cveoy.top/t/topic/mrfs 著作权归作者所有。请勿转载和采集!