文件读取
文件读取可以读取文本文件
记得在auth里面加上
file
首先我们在插件的目录创建一个1.txt
文件
插件的内容如下
// 获取API接口
const router =xBlog.router
const file = xBlog.file
// 注册路由
router.registerRouter("GET","",function(context){
file.read("1.txt",function (err,res){
if (!err){
router.response.ResponseOk(context,res)
}
})
})
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
我们调用接口,可以看到成功读取到了文件内容
编辑 (opens new window)
上次更新: 2021/07/29, 22:46:41