express静态服务_使用Express服务静态资产

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 ),该文件将被提供。

翻译自: https://flaviocopes.com/express-static-assets/

express静态服务

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值