@@ -9,12 +9,12 @@ var colors = require('colors/safe'),
99 opener = require ( 'opener' ) ,
1010 fs = require ( 'fs' ) ,
1111 argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ,
12- QRCode = require ( 'qrcode' ) ;
12+ qrcode = require ( 'qrcode-terminal ' ) ;
1313var ifaces = os . networkInterfaces ( ) ;
1414var plainIp ;
1515
1616process . title = 'http-server' ;
17-
17+ console . log ( argv )
1818if ( argv . h || argv . help ) {
1919 console . log ( [
2020 'usage: http-server [path] [options]' ,
@@ -50,6 +50,7 @@ if (argv.h || argv.help) {
5050 ' -S --ssl Enable https.' ,
5151 ' -C --cert Path to ssl cert file (default: cert.pem).' ,
5252 ' -K --key Path to ssl key file (default: key.pem).' ,
53+ ' -Q --qr-code Show QR code for public IP' ,
5354 '' ,
5455 ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]' ,
5556 ' --no-dotfiles Do not show dotfiles' ,
@@ -132,7 +133,8 @@ function listen(port) {
132133 showDotfiles : argv . dotfiles ,
133134 mimetypes : argv . mimetypes ,
134135 username : argv . username || process . env . NODE_HTTP_SERVER_USERNAME ,
135- password : argv . password || process . env . NODE_HTTP_SERVER_PASSWORD
136+ password : argv . password || process . env . NODE_HTTP_SERVER_PASSWORD ,
137+ showQR : argv . Q || argv [ 'qr-code' ]
136138 } ;
137139
138140 if ( argv . cors ) {
@@ -203,9 +205,11 @@ function listen(port) {
203205 if ( typeof proxy === 'string' ) {
204206 logger . info ( 'Unhandled requests will be served from: ' + proxy ) ;
205207 }
206- QRCode . toString ( plainIp , { type : 'terminal' } , function ( err , qr ) {
207- console . log ( qr ) ;
208- } )
208+ if ( options . showQR ) {
209+ qrcode . generate ( plainIp , { small : true } , function ( qr ) {
210+ console . log ( qr ) ;
211+ } )
212+ }
209213 logger . info ( 'Hit CTRL-C to stop the server' ) ;
210214 if ( argv . o ) {
211215 const openHost = host === '0.0.0.0' ? '127.0.0.1' : host ;
0 commit comments