怎样用 Koa 搭配 fs 模块返回一个 html 文件给前端

index.js

const fs = require("fs");
const Koa = require("koa");
const app = new Koa();

app.use(async (ctx) => {
  const html = fs.readFileSync("./index.html", "binary");
  ctx.body = html;
});

app.listen(3000);

posted on 2021-09-09 10:11  aisowe  阅读(705)  评论(0编辑  收藏  举报

导航