Express内置中间件
处理请求体中application/x-www-form-urlencoded格式的数据
express.urlencoded();
extended必须传参数{extended:false}
extended:false 表示内部使用querystring模块,推荐
extended:true 表示内部使用qs模块
qs模块可以解析更复杂的字符串,这里没必要使用
qs: https://www.npmjs.com/package/qs
处理请求体中application/json格式的数据
express.json();
提供静态资源
通过/static 来访问静态资源
app.use('/static',express.static(path.join(__dirname,'public')));
const path=require('path');
express.static(path)
app.use(express.static(path.join(__dirname,'public')));