静态资源托管中间件
使用express.static(root,[option])方法返回一个静态资源中间件方法,用来托管静态文件资源
const path = require("path");
app.use(express.static(path.join(__dirname, "public"), {
index: "index.html", //默认首页
maxAge: 24 * 60 * 60 * 1000 //将静态文件缓存浏览器的时间,单位毫秒
}));
发布于 2025-02-28 01-Express 1284 次阅读
使用express.static(root,[option])方法返回一个静态资源中间件方法,用来托管静态文件资源
const path = require("path");
app.use(express.static(path.join(__dirname, "public"), {
index: "index.html", //默认首页
maxAge: 24 * 60 * 60 * 1000 //将静态文件缓存浏览器的时间,单位毫秒
}));
Comments NOTHING