<commit_before>"""Package blueprint."""
import os

import magic
from flask import Blueprint, current_app, make_response, render_template

blueprint = Blueprint('packages', __name__, url_prefix='/packages')

@blueprint.route('')
def foo():
    return 'ok'

@blueprint.route('/<package_type>/<letter>/<name>/<version>',
                 methods=['GET', 'HEAD'])
def packages(package_type, letter, name, version):
    """Get the contents of a package."""
    filepath = os.path.join(current_app.config['BASEDIR'], name.lower(),
                            version.lower())
    if os.path.isfile(filepath):
        with open(filepath, 'rb') as egg:
            mimetype = magic.from_file(filepath, mime=True)
            contents = egg.read()
            return make_response(contents, 200, {'Content-Type': mimetype})
<commit_msg>Return a 404 if the package was not found<commit_after>"""Package blueprint."""
import os

import magic
from flask import Blueprint, current_app, make_response, render_template

blueprint = Blueprint('packages', __name__, url_prefix='/packages')

@blueprint.route('')
def foo():
    return 'ok'

@blueprint.route('/<package_type>/<letter>/<name>/<version>',
                 methods=['GET', 'HEAD'])
def packages(package_type, letter, name, version):
    """Get the contents of a package."""
    filepath = os.path.join(current_app.config['BASEDIR'], name.lower(),
                            version.lower())
    if os.path.isfile(filepath):
        with open(filepath, 'rb') as egg:
            mimetype = magic.from_file(filepath, mime=True)
            contents = egg.read()
            return make_response(contents, 200, {'Content-Type': mimetype})
    return make_response('Package not found', 404)

{'fraction_non_alphanumeric': 0.14598961338718985, 'fraction_numerical': 0.006924408540103866, 'mean_word_length': 3.378787878787879, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1545833', 'n_tokens_mistral': 516, 'n_tokens_neox': 503, 'n_words': 127}