var path = require("path"); var fs = require("fs"); exports.expressCreateServer = function (hook_name, args, cb) { args.app.get('/tests/frontend/specs_list.js', function(req, res){ fs.readdir('tests/frontend/specs', function(err, files){ if(err){ return res.send(500); } res.send("var specs_list = " + JSON.stringify(files.sort()) + ";\n"); }); }); args.app.get('/tests/frontend/*', function (req, res) { var subPath = req.url.substr("/tests/frontend".length); if (subPath == ""){ subPath = "index.html" } subPath = subPath.split("?")[0]; var filePath = path.normalize(__dirname + "/../../../../tests/frontend/") filePath += subPath.replace("..", ""); res.sendfile(filePath); }); args.app.get('/tests/frontend', function (req, res) { res.redirect('/tests/frontend/'); }); }