'use strict';

var express = require('express');
var cons = require('consolidate');
var favicon = require('serve-favicon');
var path = require('path');
var routes = require('./routes');
var app = express();

app.engine('html', cons.handlebars);
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'views'));

// middleware
app.use(express.static(path.join(__dirname, 'public')));// 静态目录
app.use(favicon(__dirname + '/static/favicon.ico'));// favicon
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(routes);


// 如果有任何错误都会设置成 404错误
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

// 如果环境设置成 开发模式，那么会打印出详细的错误信息
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// 生产模式下，不会泄漏error
app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}  // 不会泄漏error
    });
});

module.exports = app;
@@ -201,16 +201,49 @@
 ess();%0A%0A
+%0Aapp.configure(function () %7B%0A    
 app.engi
@@ -271,16 +271,20 @@
 ebars);%0A
+    
 app.set(
@@ -307,16 +307,20 @@
 html');%0A
+    
 app.set(
@@ -364,23 +364,492 @@
 ));%0A
-%0A// middleware%0A
+    // middleware%0A    app.use(express.static(path.join(__dirname, 'public')));// %E9%9D%99%E6%80%81%E7%9B%AE%E5%BD%95%0A    app.use(favicon(__dirname + '/static/favicon.ico'));// favicon%0A    app.use(express.logger('dev'));%0A    app.use(express.bodyParser());%0A    app.use(express.methodOverride());%0A    app.use(routes);%0A%7D);%0A%0Aapp.configure('development', function () %7B%0A    app.engine('html', cons.handlebars);%0A    app.set('view engine', 'html');%0A    app.set('views', path.join(__dirname, 'views'));%0A    // middleware%0A    
 app.
@@ -908,16 +908,20 @@
 // %E9%9D%99%E6%80%81%E7%9B%AE%E5%BD%95%0A
+    
 app.use(
@@ -975,16 +975,20 @@
 favicon%0A
+    
 app.use(
@@ -1007,24 +1007,28 @@
 er('dev'));%0A
+    
 app.use(expr
@@ -1042,24 +1042,28 @@
 yParser());%0A
+    
 app.use(expr
@@ -1085,16 +1085,20 @@
 ide());%0A
+    
 app.use(
@@ -1106,16 +1106,19 @@
 outes);%0A
+%7D);
 %0A%0A// %E5%A6%82%E6%9E%9C%E6%9C%89

modify app configure