There are a couple of qr code libraries on cpan, but I stopped looking when the first one worked:
cpanfile
:
requires 'Image::PNG::QRCode', '0.10';
requires 'Mojolicious', '9.35';
$ carton install
qrthing
:
#!perl
use Mojolicious::Lite -signatures;
use Image::PNG::QRCode 'qrpng';
use Mojo::Util 'b64_encode';
get '/' => sub ($c) {
my $blob = qrpng(text => $c->url_for('sekrit', {code => 1234})->to_abs);
$c->stash(template => 'index', 'img' => b64_encode $blob)
};
get '/sekrit/:code' => sub ($c) {
$c->render(text => 'secret area');
}, 'sekrit';
app->start
__DATA__
@@ index.html.ep
Scan me:
<img src="data:image/png;base64,<%= $img %>">
We can fire up the webserver the regular mojo way:
$ carton exec -- local/bin/hypnotoad ./qrthing
We've all seen a qr code before, so i think it's Ok to skip the screen shot...
That's it
I just think it's neat.