Created
July 26, 2013 00:29
-
-
Save joaoneto/6085097 to your computer and use it in GitHub Desktop.
This gist is to climb a static server, with just one command, to test the examples of several projects that need a web server.
Usage: $ npm install express; curl -ks https://gist.github.com/joaoneto/6085097/raw/761598ddb44f390179617702740fe7fbf62f6187/demo.js | node
This file contains hidden or 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'), | |
app = express(), | |
port = process.argv[2] || process.env.PORT || 9000, | |
webroot = process.argv[3] || process.env.WEBROOT || './demo'; | |
app | |
.use(express.bodyParser()) | |
.use(express.cookieParser()) | |
.use(app.router) | |
.use(express.static(__dirname + '/' + webroot)) | |
.listen(port, function () { console.log('Demo is running on: http://localhost:' + port); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Default usage:
Changing
PORT
:Changing
WEB_ROOT
folder:Changing
PORT
andWEB_ROOT
: