Skip to content

Commit 0a91929

Browse files
committed
Changed qr package from qrcode to qrcode-terminal
1 parent 0a35b4f commit 0a91929

File tree

4 files changed

+73
-395
lines changed

4 files changed

+73
-395
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ This will install `http-server` globally so that it may be run from the command
6363
|`-S` or `--ssl` |Enable https.| |
6464
|`-C` or `--cert` |Path to ssl cert file |`cert.pem` |
6565
|`-K` or `--key` |Path to ssl key file |`key.pem` |
66+
|`-Q` or `--qr-code` |Show QR code for public IP | |,
6667
|`-r` or `--robots` | Automatically provide a /robots.txt (The content of which defaults to `User-agent: *\nDisallow: /`) | `false` |
6768
|`--no-dotfiles` |Do not show dotfiles| |
6869
|`--mimetypes` |Path to a .types file for custom mimetype definition| |

bin/http-server

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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');
1313
var ifaces = os.networkInterfaces();
1414
var plainIp;
1515

1616
process.title = 'http-server';
17-
17+
console.log(argv)
1818
if (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

Comments
 (0)