text: var express = require('express');
  var path = require('path');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var favicon = require('serve-favicon');
  
  var users = require('./routes/users');
  
  var app = express();
  app.all('*', function(req, res, next) { // 解决跨域问题的
      console.log(req.method);
      res.header("Access-Control-Allow-Origin", "*");
      res.header('Access-Control-Allow-Methods', 'OPTIONS,GET,POST,PUT,DELETE');
      res.header("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Authorization");
      res.header("cache-control", "no-cache");
      res.header("content-type", "application/json; charset=utf-8");
      res.header("ETag", '');
      //header头信息设置结束后，结束程序往下执行，返回
      if(req.method.toLocaleLowerCase() === 'options'){
          res.status(200);
          return res.json({});   //直接返回空数据，结束此次请求
      }else{
          next();
      }
  })
  // uncomment after placing your favicon in /public
  app.use(favicon(path.join(__dirname, 'public', 'favicon.png')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use('/angular', express.static(__dirname + '/node_modules/angular'));
  
  app.use('/users', users);
  
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
  });
  
  // error handler
  app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
  
    // render the error page
    res.status(err.status || 500);
    res.render('error');
  });
  
  module.exports = app;
  