库房摄像头直播后台
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

4 years ago
  1. var express = require('express');
  2. var router = express.Router();
  3. var path = require("path");
  4. var fs = require("fs");
  5. /* GET home page. */
  6. router.get('/', function (req, res, next) {
  7. var imgs = ''
  8. var dirs = [];
  9. var pathName = "./public/images/";
  10. res.setHeader("Content-Type", "text/html;charset=utf-8")
  11. fs.readdir(pathName, function (err, files) {
  12. for (var i = 0; i < files.length; i++) {
  13. var img = `<div><img data-src="/imgs/${files[i]}" /></div>`
  14. imgs +=img
  15. fs.writeFile('E:\\ht.txt', imgs, function (error) {
  16. if (error) {
  17. console.log('写入失败')
  18. } else {
  19. console.log('写入成功了')
  20. }
  21. })
  22. //console.log(imgs)
  23. fs.stat(path.join(pathName, files[i]), function (err, data) {
  24. if (data.isFile()) {
  25. dirs.push(files[i]);
  26. }
  27. });
  28. }
  29. })
  30. res.end()
  31. });
  32. module.exports = router;