Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

用 koa-static 搭建静态资服务器没法显示文件列表吗?

$
0
0

用下面的代码简单的搭建一个静态资源服务,static目录包含111111.png

访问localhost:3000显示的是index.html内容,没有static目录的列表像这样这种: 222222.png

但是访问具体的文件都可以访问到,就是没办法显示整个列表,这样正常么?

const Koa = require('koa')
const path = require('path')
const static = require('koa-static')
const app = new Koa() 
const staticPath = './static'
app.use(static(path.join(__dirname, staticPath)))
app.use(async (ctx) => {
    ctx.body = 'hello world'
})
app.listen(3000)

Viewing all articles
Browse latest Browse all 14821

Trending Articles