Created
February 7, 2014 16:54
-
-
Save bloodyowl/8866790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express") | |
, http = require("http") | |
, path = require("path") | |
, app = express() | |
, parameters = process.argv.slice(2) | |
, port = parameters[0] && parseInt(parameters[0], 10) || 8080 | |
, colors = { | |
green: function (str) { | |
return "\033[0m\033[32m" + str + "\033[0m" | |
}, | |
blue: function (str) { | |
return "\033[0m\033[34m" + str + "\033[0m" | |
}, | |
red: function (str) { | |
return "\033[0m\033[33m" + str + "\033[0m" | |
} | |
} | |
console.log("\n " + colors.red("Server.\n") + " ---\n") | |
app.configure(function () { | |
app.use(express.compress()) | |
app.set("port", port) | |
app.use(express.bodyParser()) | |
app.use(express.logger("dev")) | |
app.use(express.static(path.join(__dirname, '../'))) | |
}) | |
app.get("/path/:stuff", function (req, res) { | |
res.set("Content-Type", "application/json") | |
res.send("string, mock file …") | |
}) | |
http.createServer(app).listen(app.get("port"), function () { | |
console.log(colors.blue(" Test server running on port ") + colors.green(app.get("port")) + "\n") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment