本文共 510 字,大约阅读时间需要 1 分钟。
express静态服务
It’s common to have images, CSS and more in a public
subfolder, and expose them to the root level:
通常在public
子文件夹中包含图像,CSS等,然后将其公开到根目录:
const express = require('express')const app = express()app.use(express.static('public'))/* ... */app.listen(3000, () => console.log('Server ready'))
If you have an index.html
file in public/
, that will be served if you now hit the root domain URL (http://localhost:3000
)
如果您在public/
有一个index.html
文件,那么如果您现在访问根域URL( http://localhost:3000
),该文件将被提供。
翻译自:
express静态服务
转载地址:http://qaqgb.baihongyu.com/