node.js自学日记——day4

P50、复习

P51、路径问题

P52、 express demo 

P53、 自动重启服务

 P54、express中的static-server静态资源服务

 

P55、express 配置 art-template

//下载两个  
npm install --save art-template express-art-template

 

P57、在 express 中配置解析表单 post

除了表单提交和ajax请求有 post 请求,其他大多都是 get请求,

比如直接在地址栏里请求数据,永远是get 请求 

 
 // 0. 安装 express 框架
 // 1. 进行引入
 var express = require('express')

 // 2、创建服务器应用程序,也就是原来的 http.createServer
 var app = express()


//  引入中间件,可以帮助post表单提交
var bodyParser = require('body-parser')



//  公开指定目录,大多是静态资源
app.use('/public/',express.static('./public/'))



// 配置使用 art-template 模板引擎
app.engine('html',require('express-art-template'))



//  当服务器收到 get 请求 / 的时候, 将会处理回调函数 
 app.get('/',function(req,res){

 	res.render('demo.html',{
 		name:"liuya"
 	})

 }) 


//相对于 server.listen
app.listen(3000,function(){
 
	console.log('app is running at port 3000')
})

P58、crud 起步  

P60、上午总结

P61、设计路由

P62、路由模块的提取

 P63、处理添加和 body-parse 中间件

 

 

 

猜你喜欢

转载自blog.csdn.net/weixin_42413153/article/details/84262126