生于理想

导航

随笔分类 -  Express插件

formidable--文件上传功能
摘要:npm install formidable // 引入formidable第三方模块 const formidable = require('formidable'); const path = require('path'); module.exports = (req, res) => { c 阅读全文

posted @ 2022-09-26 17:02 生于理想 阅读(151) 评论(0) 推荐(0)

bcrypt 密码加密
摘要:哈希加密是单程加密方式: 1234=>abcd 在加密的密码中加入随机字符串可以增加密码被破解的难度 // 导入bcrypt模块 const bcrypt = require('bcrypt') // 生成随机字符串 gen => generate 生成 salt 盐 let salt = awai 阅读全文

posted @ 2022-09-25 14:23 生于理想 阅读(270) 评论(0) 推荐(0)

app.locals
摘要:将变量设置到app.locals对象下面,这个数据在所有的模板中都可以获取到。 app.locals.users = [{ name: 'zhangsan', age: 20 },{ name: '李四', age: 30 }] 在模板中循环遍历 <ul> {{each users}} <li> { 阅读全文

posted @ 2022-09-23 17:36 生于理想 阅读(60) 评论(0) 推荐(0)

Express路由参数
摘要:// 引入express框架 const express = require('express'); const bodyParser = require('body-parser'); // 创建网站服务器 const app = express(); app.get('/index/:id/:n 阅读全文

posted @ 2022-09-23 17:09 生于理想 阅读(19) 评论(0) 推荐(0)

Express中GET,POST参数获取
摘要:GET Express框架中使用req.query即可获取GET参数,框架内部会将GET参数转换为对象并返回。 // 引入express框架 const express = require('express'); // 创建网站服务器 const app = express(); app.get(' 阅读全文

posted @ 2022-09-23 17:08 生于理想 阅读(87) 评论(0) 推荐(0)

express框架中配置模板引擎
摘要:npm安装 npm install art-template express-art-template 使用 const express = require('express'); const path = require('path'); const app = express(); // 1.告 阅读全文

posted @ 2022-09-23 17:04 生于理想 阅读(63) 评论(0) 推荐(0)