<commit_before>use Bailador::Context;
use Bailador::Route;
use Bailador::Template::Mojo;
use Bailador::Sessions;
use Bailador::Sessions::Config;
use Bailador::Exceptions;
use Bailador::ContentTypes;

class Bailador::App does Bailador::Routing {
    has Str $.location is rw;
    has Bailador::ContentTypes $.content-types = Bailador::ContentTypes.new;
    has Bailador::Context  $.context  = Bailador::Context.new;
    has Bailador::Template $.renderer is rw = Bailador::Template::Mojo.new;
    has Bailador::Sessions::Config $.sessions-config = Bailador::Sessions::Config.new;
    has Bailador::Sessions $!sessions;


    method request  { $.context.request  }
    method response { $.context.response }
    method template(Str $tmpl, *@params) {
        $!renderer.render(slurp("$.location/views/$tmpl"), @params);
    }

    multi method render($result) {
        if $result ~~ IO::Path {
            my $type = $.content-types.detect-type($result);
            self.render: content => $result.slurp, :$type;
        }
        else {
            self.render(content => $result);
        }
    }

    multi method render(Int :$status = 200, Str :$type = 'text/html', :$content!) {
        $.context.autorender = False;
        self.response.code = $status;<commit_msg>allowed rendering of binary files<commit_after>use Bailador::Context;
use Bailador::Route;
use Bailador::Template::Mojo;
use Bailador::Sessions;
use Bailador::Sessions::Config;
use Bailador::Exceptions;
use Bailador::ContentTypes;

class Bailador::App does Bailador::Routing {
    has Str $.location is rw;
    has Bailador::ContentTypes $.content-types = Bailador::ContentTypes.new;
    has Bailador::Context  $.context  = Bailador::Context.new;
    has Bailador::Template $.renderer is rw = Bailador::Template::Mojo.new;
    has Bailador::Sessions::Config $.sessions-config = Bailador::Sessions::Config.new;
    has Bailador::Sessions $!sessions;


    method request  { $.context.request  }
    method response { $.context.response }
    method template(Str $tmpl, *@params) {
        $!renderer.render(slurp("$.location/views/$tmpl"), @params);
    }

    multi method render($result) {
        if $result ~~ IO::Path {
            my $type = $.content-types.detect-type($result);
            self.render: content => $result.slurp(:bin), :$type;
        }
        else {
            self.render(content => $result);
        }
    }

    multi method render(Int :$status = 200, Str :$type = 'text/html', :$content!) {
        $.context.autorender = False;
        self.response.code = $status;
{'fraction_non_alphanumeric': 0.1484801247077163, 'fraction_numerical': 0.002338269680436477, 'mean_word_length': 3.3288364249578413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5174156', 'n_tokens_mistral': 821, 'n_tokens_neox': 813, 'n_words': 173}