<commit_before>import base64

from flask import Blueprint, Response, request

from newspipe.controllers import IconController
from newspipe.web.lib.view_utils import etag_match

icon_bp = Blueprint("icon", __name__, url_prefix="/icon")


@icon_bp.route("/", methods=["GET"])
@etag_match
def icon():
    try:
        icon = IconController().get(url=request.args["url"])
        headers = {"Cache-Control": "max-age=86400", "Content-Type": icon.mimetype}
        return Response(base64.b64decode(icon.content), headers=headers)
    except:
        headers = {"Cache-Control": "max-age=86400", "Content-Type": "image/gif"}
        return Response(
            base64.b64decode(
                "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
            ),
            headers=headers,
        )<commit_msg>do not use base exception<commit_after>import base64

from flask import Blueprint, Response, request

from newspipe.controllers import IconController
from newspipe.web.lib.view_utils import etag_match

icon_bp = Blueprint("icon", __name__, url_prefix="/icon")


@icon_bp.route("/", methods=["GET"])
@etag_match
def icon():
    try:
        icon = IconController().get(url=request.args["url"])
        headers = {"Cache-Control": "max-age=86400", "Content-Type": icon.mimetype}
        return Response(base64.b64decode(icon.content), headers=headers)
    except Exception:
        headers = {"Cache-Control": "max-age=86400", "Content-Type": "image/gif"}
        return Response(
            base64.b64decode(
                "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
            ),
            headers=headers,
        )
{'fraction_non_alphanumeric': 0.13253012048192772, 'fraction_numerical': 0.02650602409638554, 'mean_word_length': 3.3481675392670156, 'pattern_counts': {'":': 8, '<': 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': '7218074', 'n_tokens_mistral': 554, 'n_tokens_neox': 520, 'n_words': 99}