Skip to content

Instantly share code, notes, and snippets.

@brothertao
Last active December 17, 2015 11:39
Show Gist options
  • Save brothertao/5603527 to your computer and use it in GitHub Desktop.
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
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);
@brothertao
Copy link
Author

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

@brothertao
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment