Node Note-Pray Lin
// process url const fs = require('fs') // fileSystem http.createServer((req, res) => { res.writeHead(200, { 'Content-type': 'text/html; Parse (req.parse (req.url,)) /** * Req.parse (req.url,) /** * the fs module can also be used to create files */ fs.mkdir('./images', Err => {// Creating a file is an asynchronous process if (err) throw err; Res.end (' created ')}) fs.readdir('./images', (err, files) => {// Read the contents of the directory. The callback takes two arguments (err, files), where files is an array of the names of files in the directory (excluding '.' and '.. '). for (let i = 0; i < files.length; I ++) {let curFile = files[I] fs.stat('./images/' + curFile,(err,stats)=>{ if(err) throw err; If (stats. IsDirectory ()) {the console. The log (curFile)}})}})}). Listen (3000, '127.0.0.1)Copy the code