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():
    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)

@@ -277,16 +277,29 @@
 icon():%0A
+    try:%0A    
     icon
@@ -351,16 +351,20 @@
 %22%5D)%0A    
+  
+  
 headers 
@@ -431,16 +431,20 @@
 metype%7D%0A
+    
     retu
@@ -504,8 +504,225 @@
 eaders)%0A
+    except:%0A        headers = %7B%22Cache-Control%22: %22max-age=86400%22, %22Content-Type%22: %22image/gif%22%7D%0A        return Response(base64.b64decode(%22R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==%22), headers=headers)%0A

return transparent image if no favicon are found