Last active
December 17, 2015 11:39
-
-
Save brothertao/5603527 to your computer and use it in GitHub Desktop.
simple static server use nodejs
usage: cp this file to you want serve directory and run node sss.js [port]
eg: cp sss.js /opt/www node sss.js 8888
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 connect = require('connect'); | |
var port = parseInt(process.argv[2]) || 3000; | |
var app = connect() | |
.use(connect.logger('dev')) | |
.use(connect.static(__dirname)) | |
.use(connect.directory(__dirname)) | |
.use(function(req, res){ | |
res.end('wrong url\n'); | |
}) | |
.listen(port); | |
console.log('start listen: '+ port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple static server use nodejs
usage: cp this file to you want serve directory and run
node sss.js [port]
eg:
cp sss.js /opt/www
node sss.js 8888