<commit_before># encoding: UTF-8

module Mojito::Rendering
	
	module File
		require 'pathname'
		require 'mime/types'
		require 'time'
		
		def file!(filename)
			path = Pathname === filename ? filename : Pathname.new(filename.to_s)
			
			body = FileResponse.new path
			halt! [response.status, response.headers.merge(body.compute_headers), body]
		end
		
		class FileResponse<commit_msg>add sanity checks to file renderer<commit_after># encoding: UTF-8

module Mojito::Rendering
	
	module File
		require 'pathname'
		require 'mime/types'
		require 'time'
		
		def file!(filename)
			path = Pathname === filename ? filename : Pathname.new(filename.to_s)
			restrict_path! path if respond_to? :restrict_path!
			if path.readable? and path.file?
				body = FileResponse.new path
				halt! [response.status, response.headers.merge(body.compute_headers), body]
			else
				not_found!
			end
		end
		
		class FileResponse
{'fraction_non_alphanumeric': 0.09923664122137404, 'fraction_numerical': 0.0021810250817884407, 'mean_word_length': 3.831578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '491412', 'n_tokens_mistral': 345, 'n_tokens_neox': 284, 'n_words': 76}