首页 > 代码库 > node js

node js

var exp=require(‘express‘),http=require(‘http‘);var userinfo  = require(‘./green/cheshi‘);var app=exp();app.set("port",8878);app.use(exp.static(__dirname+‘/html‘));app.set(‘view engine‘,‘ejs‘); //设置视图模块 ejsapp.set(‘views‘,__dirname+‘/green/view‘); //设置视图文件所在位置app.use(exp.favicon());app.use(exp.logger(‘dev‘));app.use(exp.bodyParser());app.use(exp.methodOverride());if(‘development‘==app.get(‘env‘)){    app.use(exp.errorHandler());};http.createServer(app).listen(app.get(‘port‘),function(){    console.log(‘Express port‘+app.get(‘port‘));});app.get(‘/deletebyid‘,function(req,res){    var tempcon = userinfo.deleteById(req.query.id, function (e,f) {        if(!e){            res.json(1);        }else{            console.log(e);            res.json(0);        }}); });app.get(‘/queryAllUser‘,function(req,res){    var tempcon = userinfo.queryAllUserInfo(function (e,r,f) {        if(!e){          var datee={show:r};            res.render("table1",datee);        } else{            console.log(e);        }        tempcon.end();    });});

 

nodejs 主要应用是前后台交互,用于数据传递。

 

node js