You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
var express = require('express');
|
|
var router = express.Router();
|
|
var path = require("path");
|
|
var fs = require("fs");
|
|
|
|
/* GET home page. */
|
|
router.get('/', function (req, res, next) {
|
|
var imgs = ''
|
|
var dirs = [];
|
|
var pathName = "./public/images/";
|
|
res.setHeader("Content-Type", "text/html;charset=utf-8")
|
|
fs.readdir(pathName, function (err, files) {
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
var img = `<div><img data-src="/imgs/${files[i]}" /></div>`
|
|
|
|
imgs +=img
|
|
fs.writeFile('E:\\ht.txt', imgs, function (error) {
|
|
if (error) {
|
|
console.log('写入失败')
|
|
} else {
|
|
console.log('写入成功了')
|
|
}
|
|
})
|
|
//console.log(imgs)
|
|
fs.stat(path.join(pathName, files[i]), function (err, data) {
|
|
if (data.isFile()) {
|
|
dirs.push(files[i]);
|
|
}
|
|
});
|
|
}
|
|
})
|
|
res.end()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|