代码拉取完成,页面将自动刷新
const Koa = require("koa");
const http = require("http");
const static = require("./koa-static-router");
// const router = require("koa-router")();
const app = new Koa();
// 单个路由
// app.use(static({
// dir:'public',
// router:'/static/' //路由长度 =1
// }))
//多个路由
app.use(
static([
{
dir: "public",
router: "/public/image/",
},
{
dir: "static",
router: "/static/image/",
},
])
);
// app.use(async (ctx) => {
// ctx.body = "hello world";
// });
// app.use(router.routes()); //作用:启动路由
app.listen(3030, () => {
console.log("build success");
});
// http.createServer(app.callback()).listen(3030);
console.log("the server is running on 3030");
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。