美文网首页
koa2小结

koa2小结

作者: 天天向上er | 来源:发表于2019-10-23 10:50 被阅读0次

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')

})

相关文章

网友评论

      本文标题:koa2小结

      本文链接:https://www.haomeiwen.com/subject/crbhvctx.html