3 ms·
I'm surprised there's no one-liner for Node without dependency since it has a server by default. Edit: Didn't know there was an `eval` flag for Node, so that w
by laurent123456 7y ago
I'm surprised there's no one-liner for Node without dependency since it has a server by default.
Edit: Didn't know there was an `eval` flag for Node, so that will do the job:
node --eval "var fs = require('fs'), http = require('http'); http.createServer(function (req, res) { fs.readFile(__dirname + req.url, function (err,data) { if (err) { res.writeHead(404); res.end(JSON.stringify(err)); return;}res.writeHead(200);res.end(data); });}).listen(8080);"
- hombre_fatal 7y agoDoesn't protect against folder climbing/traversal like `curl :8080/../../etc`.
- djsumdog 7y agoHuh .. that'd be a fun post; see how many of these can be susceptible for climbing out of their web root. The author does list which ones support dir indexes.
- pvillano 7y agohopefully you're not using a one-liner for your actual deployment. I use it for no stakes development
- hombre_fatal 7y agoCaddy is a one-liner. Plenty of the one-liners are suitable for production. There are so many solutions that you might as well use one, even in development, that doesn't have such glaring issues, because you're basically training your muscle memory to reach for it.
- laurent123456 7y agoMost of these one-liner probably aren't secure. As the title post says "Use this power wisely".
- vorticalbox 7y agonpx http-server -p 8080