Skip to content

Commit

Permalink
added public dir as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
muka committed Jan 28, 2015
1 parent 672fe2f commit 9176bf6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var express = require("express"),
errorHandler = require('errorhandler'),
methodOverride = require('method-override'),
hostname = process.env.HOSTNAME || 'localhost',
port = parseInt(process.env.PORT, 10) || 4567;
port = parseInt(process.env.PORT, 10) || 4567,
publicDir = process.argv[2] || __dirname + '/public';

app.get("/", function (req, res) {
res.redirect("/index.html");
Expand All @@ -15,11 +16,11 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static(__dirname + '/public'));
app.use(express.static(publicDir));
app.use(errorHandler({
dumpExceptions: true,
showStack: true
}));

console.log("Simple static server listening at http://" + hostname + ":" + port);
console.log("Simple static server showing %s listening at http://%s:%s", publicDir, hostname, port);
app.listen(port, hostname);

0 comments on commit 9176bf6

Please sign in to comment.