diff --git a/bin/http-server b/bin/http-server index 28c41389..72e582a3 100755 --- a/bin/http-server +++ b/bin/http-server @@ -1,8 +1,21 @@ #!/usr/bin/env node -var HTTPServer = require('../lib/http-server').HTTPServer; +var HTTPServer = require('../lib/http-server').HTTPServer, + fs = require('fs'), + path = require('path'), + config = null; -var httpServer = new HTTPServer(); +if (path.existsSync("./config.json")) { + console.log("Found configuration file ".green + "`./config.json`".cyan); + + try { + config = JSON.parse(fs.readFileSync("./config.json").toString()) + } catch (e) { + console.log("Error parsing ".red +"`./config.json`: ".cyan+("\""+e.message+"\"") + "; Ignoring.".yellow); + } +} + +var httpServer = new HTTPServer(config); httpServer.start(); diff --git a/config.json b/config.json new file mode 100644 index 00000000..01349e16 --- /dev/null +++ b/config.json @@ -0,0 +1,4 @@ +{ + "root": "./public", + "port": 8080 +}