Last active
November 17, 2016 02:01
-
-
Save brenapp/98ccf4c976ef5f3b959be4f8ac228c31 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
npm i -g express & curl -o /usr/local/bin/serve https://gist.githubusercontent.com/MayorMonty/98ccf4c976ef5f3b959be4f8ac228c31/raw/e895f30bf37858b52f92ad285eeafc35a2087549/serve.js |
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
#!/usr/bin/env node | |
var express = require("express"), | |
path = require("path"), | |
fs = require("fs"), | |
app = express(), | |
root = path.resolve(process.argv[2] || process.cwd()); | |
app.use(function(req, res, next) { | |
console.log(`${req.method} ${req.url} `); | |
next(); | |
}); | |
app.use(express.static(root)); | |
app.use(function(req, res) { | |
res.end("Your request could not be handled."); | |
}); | |
var port = process.argv[4] || 3000, | |
ip = process.argv[3] || "0.0.0.0"; | |
app.listen(port, ip, 511, function() { | |
console.log(`Serving ${root} at ${ip}:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment