<commit_before>require "rack/qrcode/version"
require 'rqrcode_png'
require "cgi"

module Rack
  class Qrcode
    def initialize(app, options = {})
      @app  = app
      @path = options[:path] || '/qrcode'
    end

    def call(env)
      return @app.call(env) unless env['PATH_INFO'] == @path

      params = CGI.parse(env["QUERY_STRING"])
      if params['text'].empty?
        return [400, {'Content-Type' => 'text/html'}, ["Bad Request"]]
      end
      text   = params['text'].first
      size   = params['size'].empty?  ?  4 : params['size'].first.to_i
      level  = params['level'].empty? ? :h : params['level'].first.to_sym
      width  = params['width'].empty?  ? 200 : params['width'].first.to_i
      height = params['height'].empty? ? 200 : params['height'].first.to_i
      qr  = RQRCode::QRCode.new(text, size: size, level: level)
      png = qr.to_img
      body = png.resize(width, height).to_blob
      headers = {
        "Content-Length" => body.bytesize.to_s,
        "Content-Type"   => "imgae/png",
        "Last-Modified"  => Time.now.httpdate
      }

      [200, headers, [body]]
    end
  end
end<commit_msg>Fix typo<commit_after>require "rack/qrcode/version"
require 'rqrcode_png'
require "cgi"

module Rack
  class Qrcode
    def initialize(app, options = {})
      @app  = app
      @path = options[:path] || '/qrcode'
    end

    def call(env)
      return @app.call(env) unless env['PATH_INFO'] == @path

      params = CGI.parse(env["QUERY_STRING"])
      if params['text'].empty?
        return [400, {'Content-Type' => 'text/html'}, ["Bad Request"]]
      end
      text   = params['text'].first
      size   = params['size'].empty?  ?  4 : params['size'].first.to_i
      level  = params['level'].empty? ? :h : params['level'].first.to_sym
      width  = params['width'].empty?  ? 200 : params['width'].first.to_i
      height = params['height'].empty? ? 200 : params['height'].first.to_i
      qr  = RQRCode::QRCode.new(text, size: size, level: level)
      png = qr.to_img
      body = png.resize(width, height).to_blob
      headers = {
        "Content-Length" => body.bytesize.to_s,
        "Content-Type"   => "image/png",
        "Last-Modified"  => Time.now.httpdate
      }

      [200, headers, [body]]
    end
  end
end
{'fraction_non_alphanumeric': 0.16923754958131335, 'fraction_numerical': 0.011458792419568091, 'mean_word_length': 2.6146496815286624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7615262', 'n_tokens_mistral': 807, 'n_tokens_neox': 763, 'n_words': 158}