2021年6月8日
摘要: 文件结构 一.使用mongoose连接MongoDB数据库 //引入mongoose数据库 const mongoose = require("mongoose"); //连接mongodb数据库 mongoose.connect("mongodb://localhost:27017/school" 阅读全文
posted @ 2021-06-08 20:57 文种玉 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 应用中间件 /** * 应用中间件 * 1.应用中间件的作用一般用于对url的拦截 * 2.应用需要使用next对象中间件放行 * * 拓展:所有的中间件都使用了use,路由器也属于中间件的一种 */ const express = require("express"); const app = e 阅读全文
posted @ 2021-06-08 19:58 文种玉 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 搭建用户路由器 概述,路由器的作用是将功能分类,比如将user下的所有功能,都放入user路由器下 举两个例子 用户路由器 localhost:8080/user/list /** * 请求的入口 */ const express = require("express"); const app = 阅读全文
posted @ 2021-06-08 19:36 文种玉 阅读(80) 评论(0) 推荐(1) 编辑
摘要: 方式一:通过绑定数据流data事件来获取 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name=" 阅读全文
posted @ 2021-06-08 18:50 文种玉 阅读(1511) 评论(0) 推荐(0) 编辑
摘要: const express = require("express"); const app = express(); app.listen(8080); /** * 请求方式一 * http://localhost:8080/reg?username=zhangsan&password=123456 阅读全文
posted @ 2021-06-08 18:35 文种玉 阅读(373) 评论(0) 推荐(0) 编辑
摘要: const express = require("express"); //创建服务器 var app = express(); //配置服务器的端口 app.listen(8080); app.get("/login",(req,res)=>{ //普通响应 // res.end("今天天气好晴朗 阅读全文
posted @ 2021-06-08 18:25 文种玉 阅读(186) 评论(0) 推荐(0) 编辑