<commit_before>class ProxyController < ApplicationController
  skip_before_action :verify_authenticity_token, if: :js_request?
  #skip_before_action :verify_authenticity_token

  def index
    image_url = params['url']
    callback = params['callback']

    if  !image_url || !callback
      render :text => 'missing arguments', :status => 400
    end

    begin
      base64_img, ctype = download_image(image_url)
      img_data_src = build_data_img_src(base64_img, ctype)
      render :json => img_data_src.to_json, :callback => callback
    rescue
      render :json => {error: 'Application error'}, :callback => callback
    end

  end

protected
  def js_request?
    request.format.js?
  end
private

    def build_data_img_src(base64_mage, content_type)
      "data:#{content_type};base64,#{base64_mage}"
    end

    def download_image(url, encoding='base64')<commit_msg>skiping very_authenticity_token on proxy controller<commit_after>class ProxyController < ApplicationController
  skip_before_action :verify_authenticity_token

  def index
    image_url = params['url']
    callback = params['callback']

    if  !image_url || !callback
      render :text => 'missing arguments', :status => 400
    end

    begin
      base64_img, ctype = download_image(image_url)
      img_data_src = build_data_img_src(base64_img, ctype)
      render :json => img_data_src.to_json, :callback => callback
    rescue
      render :json => {error: 'Application error'}, :callback => callback
    end

  end

private

    def build_data_img_src(base64_mage, content_type)
      "data:#{content_type};base64,#{base64_mage}"
    end

    def download_image(url, encoding='base64')
{'fraction_non_alphanumeric': 0.09688995215311005, 'fraction_numerical': 0.017942583732057416, 'mean_word_length': 4.008982035928144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5918437', 'n_tokens_mistral': 550, 'n_tokens_neox': 513, 'n_words': 116}