1、路径 path
访问静态资源
const Koa = require('koa');
const path = require('path');
const static = require('koa-static');//中间件
const app = new Koa();
const staticPath = './';
app.use(static(path.join(__dirname,staticPath)))
app.use(async(ctx)=>{
ctx.body = "hello world"
})
app.listen(3000,()=>{
console.log('[3000] server is starting at port 3000')
})
网友评论