10 2021 档案

摘要:get const http = require('http'); const url = require('url'); const host = 'http://localhost:3000'; http.createServer(function (req, res) { const { se 阅读全文
posted @ 2021-10-28 10:19 zhoulixue 阅读(45) 评论(0) 推荐(0) 编辑
摘要:index.ejs <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" c 阅读全文
posted @ 2021-10-28 09:37 zhoulixue 阅读(37) 评论(0) 推荐(0) 编辑
摘要:1. 工具函数 module/file.js 读取文件数据 const fs = require('fs'); const readFile = (path) => new Promise((resolve) => { fs.readFile(path, (err, data) => { resol 阅读全文
posted @ 2021-10-21 10:07 zhoulixue 阅读(360) 评论(0) 推荐(0) 编辑
摘要:写数据流 const fs = require('fs'); let str = ''; for (let i = 0; i < 1e4; i++) { str += `写入数据${i}\n`; } const writeStream = fs.createWriteStream('./data/o 阅读全文
posted @ 2021-10-20 20:11 zhoulixue 阅读(132) 评论(0) 推荐(0) 编辑
摘要:创建一个upload文件夹 const fs = require('fs'); // 创建文件夹 const mkdir = (path) => new Promise((resolve) => { fs.mkdir(path, (err) => { resolve({ err }); }); }) 阅读全文
posted @ 2021-10-20 10:01 zhoulixue 阅读(57) 评论(0) 推荐(0) 编辑
摘要:检测是文件还是目录 const fs = require('fs'); fs.stat('./html', (err, stat) => { if (err) { console.log(err); return; } const isDirectory = stat.isDirectory(); 阅读全文
posted @ 2021-10-19 09:57 zhoulixue 阅读(74) 评论(0) 推荐(0) 编辑
摘要:new URL(input, [base]) base验证input的origin是否符合预期 let myUrl = new URL('test/index.html', 'https://example.com'); // https://example.com/test/index.html 阅读全文
posted @ 2021-10-11 09:48 zhoulixue 阅读(130) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示