npm install localtunnel serve-index express && node liveme.js
Last active
September 22, 2016 05:22
-
-
Save mashihua/ef361c0f41578539efb2a3db0834becf to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
var localtunnel = require('localtunnel'); | |
var serveIndex = require('serve-index'); | |
var express = require('express'); | |
var app = express(); | |
var port = process.env.PORT || 33333; | |
var domain = process.env.DOMAIN || undefined; | |
var dir = process.cwd(); | |
app.use(serveIndex(dir, {'icons': true})); | |
app.use(express.static(dir)); | |
app.listen(port, function () { | |
console.log('Server listen on port ' + port); | |
}); | |
var tunnel = localtunnel(port, {subdomain: domain}, function(err, tunnel) { | |
if (err){ | |
return console.error('Some error:' + err) | |
} | |
console.log('Now tunnel to: ' + tunnel.url) | |
}); | |
tunnel.on('close', function() { | |
// tunnels are closed | |
onsole.log('tunnel closed') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment