Skip to content

Instantly share code, notes, and snippets.

@seki
Created December 14, 2009 20:04
Show Gist options
  • Save seki/256373 to your computer and use it in GitHub Desktop.
Save seki/256373 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>QR</title>
</head>
<body>
<form action="http://localhost/cgi-bin/qr.rb" method="post">
<textarea name="t" cols="80" rows="15">
</textarea>
<input type="submit" name="QR" value="QR" />
</form>
</body>
</html>
#!/usr/local/bin/ruby -Ks
require 'rqr'
require 'cgi'
require 'nkf'
cgi = CGI.new
param ,= cgi['t']
text = NKF.nkf('-s', param)
puts 'Content-Type: image/png; name="qrcode.png"'
puts
begin
RQR::QRCode.create do |qr|
qr.save(text, nil, :png)
end
rescue RQR::EncodeException
RQR::QRCode.create do |qr|
qr.save('oops!', nil, :png)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment