express 框架实现一个留言板

一、express -e blog

二、cd blog && cnpm install && npm start 

三、riews   index.ejs  改提交接口

四、var add = require('../rotes/add')

  app.js 中  app.use('/',add)

五、routes  +  add.js  rotes.post('/',function(req,res){res.body.username;res.body.txt})

六、连接数据库服务器

  bin/www→var mongoose = require('mongoose');

       mongoose.connect('mongodb://127.0.0.1/hihi',function(err){如果有错误,则为写入失败})  ///如果写入数据库成功,则监听服务器端口,服务器运行成功。(在连接上数据库的前提下,连接服务器)

posted @ 2018-08-10 10:39  我不开心又如何  阅读(340)  评论(1)    收藏  举报