Last active
August 29, 2015 14:20
-
-
Save jdavisclark/4fe652a143314be98e29 to your computer and use it in GitHub Desktop.
basic console echoing debug server with built in localtunnel. need to install localtunnel
This file contains hidden or 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
| // if you want to specify a custom localtunnel subomain, just throw it in an additional argument eg: node debugWebserver.js mysubdomain | |
| var util = require("util"); | |
| var lt = require("localtunnel"); | |
| var http = require('http'); | |
| http.createServer(function (req, res) { | |
| console.log(req.method + " " + req.url) | |
| req.on("data", function(chunk) { | |
| console.log("Body: " + chunk) | |
| }); | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| res.end(''); | |
| }).listen(1337, '0.0.0.0'); | |
| var tunnel = lt(1337, { | |
| subdomain: process.argv[2] | |
| }, function(err, tunnel) { | |
| if (err) { | |
| console.log("error starting tunnel: " + err); | |
| process.exit(1); | |
| } | |
| console.log(tunnel.url) | |
| }); | |
| process.on("exit", function() { | |
| tunnel.close(); | |
| console.log("closing tunnel.."); | |
| }) | |
| process.on("SIGINT", function() { | |
| tunnel.close(); | |
| process.exit(); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment