怎样用 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);

原文地址:https://www.cnblogs.com/aisowe/p/15245760.html