local-server
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
var PORT_NUMBER = Number(process.argv[2]) || 8000, | ||
ROOT_FOLDER = './', | ||
ROOT_FOLDER = Number(process.argv[3]) || './', | ||
MIME_TYPES = { | ||
@@ -27,4 +27,5 @@ '.html' : 'text/html', | ||
if (err) { | ||
res.writeHead(err.code == 'ENOENT' ? 404: 500, { 'Content-Type': 'text/html' }) | ||
res.writeHead(err.code == 'ENOENT' ? 404 : 500, { 'Content-Type': 'text/html' }) | ||
res.end(err.toString()) | ||
console.log('Error', err) | ||
} else if (stat.isDirectory()) { | ||
@@ -42,2 +43,2 @@ handle(path.join(filePath, 'index.html')) | ||
console.log('Server running at http://localhost:' + PORT_NUMBER + '/') | ||
console.log('Server running at http://localhost:' + PORT_NUMBER + '/' + ' with root ' + ROOT_FOLDER) |
{ | ||
"name": "local-server", | ||
"main": "local-server", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Minimal zero-dependency static web server", | ||
@@ -6,0 +6,0 @@ "homepage": "http://buunguyen.github.io/local-server", |
@@ -13,7 +13,7 @@ local-server | ||
``` | ||
cd ~/somedir | ||
node ./lsrv.js [optional port] | ||
=> Server running at http://localhost:8000/ | ||
cd ~/some/dir | ||
lsrv [port, default: 8000] [root, default: current folder] | ||
=> Server running at http://localhost:8000/ with root ./ | ||
``` | ||
That's all! |
3293
4.24%36
2.86%