forked from kompetenzinventar/ki-backend
fix svg icon header
This commit is contained in:
11
ki/routes.py
11
ki/routes.py
@ -12,6 +12,9 @@ from ki.handlers import update_profile as update_profile_handler
|
||||
from ki.models import ContactType, Language, Skill, Token, User
|
||||
from app import app
|
||||
|
||||
content_type_svg = "image/svg+xml"
|
||||
content_type_png = "image/png"
|
||||
|
||||
|
||||
def token_auth(func):
|
||||
@wraps(func)
|
||||
@ -71,22 +74,22 @@ def handle_icon_request(model, id, path):
|
||||
icon_svg_path = icon_base_path + ".svg"
|
||||
|
||||
if os.path.exists(icon_svg_path):
|
||||
return send_file(icon_svg_path, mimetype="image/svg")
|
||||
return send_file(icon_svg_path, mimetype=content_type_svg)
|
||||
|
||||
icon_png_path = icon_base_path + ".png"
|
||||
|
||||
if os.path.exists(icon_png_path):
|
||||
return send_file(icon_png_path, mimetype="image/png")
|
||||
return send_file(icon_png_path, mimetype=content_type_png)
|
||||
|
||||
unknown_svg_path = path + "unknown.svg"
|
||||
|
||||
if os.path.exists(unknown_svg_path):
|
||||
return send_file(unknown_svg_path, mimetype="image/svg")
|
||||
return send_file(unknown_svg_path, mimetype=content_type_svg)
|
||||
|
||||
unknown_png_path = path + "unknown.png"
|
||||
|
||||
if os.path.exists(unknown_png_path):
|
||||
return send_file(unknown_png_path, mimetype="image/png")
|
||||
return send_file(unknown_png_path, mimetype=content_type_png)
|
||||
|
||||
return make_response({"error": "icon not found"}, 404)
|
||||
|
||||
|
Reference in New Issue
Block a user