@@ -7,14 +7,14 @@ var colors = require('colors/safe'),
77 httpServer = require ( '../lib/http-server' ) ,
88 portfinder = require ( 'portfinder' ) ,
99 opener = require ( 'opener' ) ,
10- fs = require ( 'fs' ) ;
10+ fs = require ( 'fs' ) ,
11+ qrcode = require ( 'qrcode-terminal' ) ;
1112var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) , {
1213 alias : {
1314 tls : 'ssl'
1415 }
1516} ) ;
1617var ifaces = os . networkInterfaces ( ) ;
17- var plainIp ;
1818
1919process . title = 'http-server' ;
2020if ( argv . h || argv . help ) {
@@ -53,7 +53,7 @@ if (argv.h || argv.help) {
5353 ' -S --ssl Enable https.' ,
5454 ' -C --cert Path to ssl cert file (default: cert.pem).' ,
5555 ' -K --key Path to ssl key file (default: key.pem).' ,
56- ' --qr-code Show QR code for public IP' ,
56+ ' --qr-code (Experimental) Show QR code for public IP' ,
5757 '' ,
5858 ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]' ,
5959 ' --no-dotfiles Do not show dotfiles' ,
@@ -72,6 +72,7 @@ var port = argv.p || argv.port || parseInt(process.env.PORT, 10),
7272 utc = argv . U || argv . utc ,
7373 version = argv . v || argv . version ,
7474 logger ;
75+ var plainIp = host ;
7576
7677var proxyOptionsBooleanProps = [
7778 'ws' , 'xfwd' , 'secure' , 'toProxy' , 'prependPath' , 'ignorePath' , 'changeOrigin' ,
@@ -231,6 +232,7 @@ function listen(port) {
231232 }
232233 }
233234 if ( options . showQR ) {
235+ logger . info ( colors . yellow ( "WARNING: " ) + "This is an experimental feature and is not guaranteed to work properly in all terminals or fonts." )
234236 qrcode . generate ( plainIp , { small : true } , function ( qr ) {
235237 console . log ( qr ) ;
236238 } )
0 commit comments