使用express搭建
直接上才艺
/**
* 代理html
* 注入修改html
*/
var express = require("express");
const fs = require('fs');
const path = require('path');
const ip = require('ip');
/** 端口 */
let port = 8888;
let ipAddress = ip.address();
function localServer() {
let app = express();
app.get('/', (req, res) => {
let query = req.query || {};
let number = Number(query.scale);
let data = fs.readFileSync(path.join(__dirname,'index_20.html'),'utf8');
data = data.replace(/(initial-scale=)([0-9.]+)/, '$1' + number);
res.send(data);
});
app.listen(port, () => {
console.log(`服务启动 http://127.0.0.1:${port}`);
console.log(`服务启动 http://${ipAddress}:${port}`);
});
}
localServer();
我直接复制就ok了,太简单了,我还可以把一些进常用的代码块放评论里,以后要用直接就有了。吼吼吼