1 Star 0 Fork 0

MicroPeople / koa-static

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.js 739 Bytes
一键复制 编辑 原始数据 按行查看 历史
MicroPeople 提交于 2022-02-01 22:26 . -
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");
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/MicroPeople/koa-static.git
git@gitee.com:MicroPeople/koa-static.git
MicroPeople
koa-static
koa-static
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891