koa koa-static基本配置
作者:
萘小蒽 | 来源:发表于
2020-07-21 09:29 被阅读0次const koa = require('koa');
const static = require('koa-static');
const fs = require('fs');
const KoaRouter = require('koa-router');
const router = KoaRouter();
const app = new koa();
app.use(static(__dirname+'/source/'));
router.get('/',(ctx)=>{
ctx.response.type = 'html';
ctx.response.body = fs.createReadStream(__dirname+'/source/index.html');
});
app.use(router.routes())//启动路由
app.listen(3000);
本文标题:koa koa-static基本配置
本文链接:https://www.haomeiwen.com/subject/kohekktx.html
网友评论