首先用lua遍历目录:

 function getDirs(path)
local s = {}
function attrdir(p)                  
for file in lfs.dir(p) do
if file ~= "." and file ~= ".." then
local f = p .. file
local attr = lfs.attributes (f)
if attr.mode == "directory" then
table.insert(s, f)
attrdir(f .. "/")
else
table.insert(s, f)
end
end
end
end
attrdir(path)
return s
end

  然后将结果打包成JSON格式用于传递:

 function string2JSON(path)
local s = getDirs(path)
local cjson = require("cjson")
local sJson = cjson.encode(s)
return sJson
end

  最后用lwt后台输出到页面中:

 require "httpd"
require "lfs" request, args = ... function getDirs(path)
local s = {}
function attrdir(p)
for file in lfs.dir(p) do
if file ~= "." and file ~= ".." then
local f = p .. file
local attr = lfs.attributes (f)
if attr.mode == "directory" then
table.insert(s, f)
attrdir(f .. "/")
else
table.insert(s, f)
end
end
end
end
attrdir(path)
return s
end function string2JSON(path)
local s = getDirs(path)
local cjson = require("cjson")
local sJson = cjson.encode(s)
return sJson
end httpd.set_content_type("text/plain")
httpd.write(string2JSON(request.filedir))

最新文章

  1. PHP 适配器模式
  2. SQL Server 更改跟踪(Chang Tracking)监控表数据
  3. 软件工程(FZU2015)学生博客列表(最终版)
  4. 大熊君大话NodeJS之------Http模块
  5. 服务器设置SSH 长连接
  6. PHP异步工作避免程序运行超时
  7. 怎样在Eclipse中使用debug模式调试程序
  8. 设计模式(一)工厂模式Factory(创建类型)
  9. Ubuntu 14.04 待机死机问题原来是自己改了这个配置
  10. [LeetCode] Find Duplicate File in System 在系统中寻找重复文件
  11. java线程的同步控制--重入锁ReentrantLock
  12. ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing
  13. T-shirt 0 0....
  14. java常用技术名词解析
  15. CH4701 天使玩偶
  16. 20155306 白皎 《网络攻防》 EXP7 网络欺诈技术防范
  17. ASP.NET MVC异常处理方案
  18. pthread_once重塑singleton模式
  19. 51nod 1307 绳子与重物(并查集水了一发)
  20. Python数据分析工具库-Numpy 数组支持库(二)

热门文章

  1. CodeForces 146E Lucky Subsequence(组合数+DP)
  2. hibernate:对于java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I错误解决办法
  3. no getter for property named 'power_state
  4. [原创] 改善 Firemonkey Canvas 几何绘图质量问题(移动平台)
  5. where语句中多条件查询字段NULL与NOT NULL不确定性查询
  6. JulyNovel-React
  7. centos 7 安装mysql5.6rpm格式
  8. 算法 UVA 11300
  9. 导出包含图片的excel、word、pdf 笔记
  10. selenium alert JS弹窗问题处理