代码拉取完成,页面将自动刷新
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var path = require('path');
var fs = require('fs');
var RedisStore = require('connect-redis')(express);
var routes = require('./routes');
var settings = require('./settings.json');
var ejser = require('./middlewares/ejser.js');
var run_instance = function(port){
var app = express();
// all environments
app.set('port', port || process.env.PORT);
app.set('views', path.join(__dirname, 'views'));
//app.set('view engine', 'ejs');
app.engine('.html', ejser.EJS().renderFile);//or app.engine('.html', require('ejs').__express);
app.set('view engine', 'html');//change ejs template suffix to .html
app.set('jsonp callback', true);
app.use(express.favicon(path.join(__dirname,'public/images/favicon.ico')));
app.use(express.compress());
//logger
var accessLogfile = fs.createWriteStream('logs/access.log', {flags: 'a'});
var errorLogfile = fs.createWriteStream('logs/error.log', {flags: 'a'});
app.use(express.logger({stream: accessLogfile}));
app.configure('production', function() {
app.use(function(err, req, res, next){
var meta = '[' + new Date() + '] ' + req.url + '\n';
errorLogfile.write(meta + err.stack + '\n');
next();
});
});
//app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.bodyParser({ keepExtensions: true,uploadDir:'./public/uploads'}));
app.use(express.cookieParser(settings['session_secret']));
//app.use(express.session());
app.use(express.session({
secret:settings['session_secret'],
store:new RedisStore(settings['session_redis_db'])
}));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
routes(app);//mapping routes
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
}
exports.run = run_instance;
if(!module.parent) {
run_instance(80);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。