Skip to content

Instantly share code, notes, and snippets.

@gildean
Created January 15, 2013 17:42
Show Gist options
  • Save gildean/4540408 to your computer and use it in GitHub Desktop.
Save gildean/4540408 to your computer and use it in GitHub Desktop.
express fileshare
module.exports = function (port, path) {
"use strict";
var http = require('http'),
express = require('express'),
app = express(),
server = http.createServer(app),
path = path || __dirname,
port = port || 8555;
app.use(express.static(path));
app.use(express.directory(path));
app.use(function (req, res) {
res.send(418, 'No coffee.');
});
server.listen(parseInt(port), function () {
var address = server.address();
console.log('Serving ' + path + ' on: ' + address.address + ':' + address.port);
});
};
#!/usr/bin/env node
var arguments = process.argv.slice(2);
var server = require('./index')(arguments[0], arguments[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment