Skip to content

Commit

Permalink
Adding port and diff environemnt related settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipiyer committed Oct 19, 2012
1 parent d6da2b7 commit d6fe236
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@
*.rej
bin/*
log
.#*
33 changes: 18 additions & 15 deletions app.js
Expand Up @@ -7,30 +7,33 @@ PROJDIR = __dirname;
var app = module.exports = express();

app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('view engine', 'jade');
app.set("views", path.join(PROJDIR,"templates"));
app.set("views", path.join(PROJDIR, "templates"));
app.use(express.favicon());
app.use(express.logger('dev'));
var media = path.join(PROJDIR, 'media');
app.use(express.static(media));
app.get(/\/js/, express.static(path.join(media,'js')));
app.get(/\/css/, express.static(path.join(media,'css')));
app.get(/\/images/, express.static(path.join(media,'images')));
var static = path.join(PROJDIR, 'static');
app.use(express.static(static));
app.get(/\/js/, express.static(path.join(static,'js')));
app.get(/\/css/, express.static(path.join(static,'css')));
app.get(/\/images/, express.static(path.join(static,'images')));
app.use(express.bodyParser());
app.use(express.methodOverride());
// Example 500 page
});

app.configure('development', function(){
app.use(express.errorHandler());
});

app.configure('production', function(){
app.use(function(err, req, res, next){
console.log(err);
res.status(500);
res.render('500.jade', {"error": err, "status":500});
});
});

app.configure('development', function(){
app.use(express.errorHandler());
});

var INSTALLED_APPS = ['./hello']
var INSTALLED_APPS = ['./hello'];


// Import URL dispatcher
Expand All @@ -50,6 +53,6 @@ app.all('*', function(req, res){
});


http.createServer(app).listen(3000);

console.log("Express server listening on port 3000");
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
4 changes: 2 additions & 2 deletions hello/views.js
@@ -1,6 +1,6 @@
exports.hello = function(req, res, next){
conole.log('Hello World');
console.log('Hello World');
res.render('hello/index.jade',
{ title: 'Express' })
{ title: 'Express' });
}

0 comments on commit d6fe236

Please sign in to comment.