aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-06-25 14:58:09 +0100
committerrubenwardy <rw@rubenwardy.com>2020-06-25 14:58:09 +0100
commitecb3d83c57b00684e2cc1b8740df3df4510be720 (patch)
treed9a3ac5a480f6d98e2a5ab7b05a2dcaab2586a81
parent2cfb59d0428b3b22b540bd5e7bfc156bbd4f9f75 (diff)
downloadcheatdb-ecb3d83c57b00684e2cc1b8740df3df4510be720.tar.xz
Fix FileNotFoundError on missing thumbnail source
-rw-r--r--app/blueprints/thumbnails/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/blueprints/thumbnails/__init__.py b/app/blueprints/thumbnails/__init__.py
index 109cc0c..dbfdfc5 100644
--- a/app/blueprints/thumbnails/__init__.py
+++ b/app/blueprints/thumbnails/__init__.py
@@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-from flask import *
+from flask import abort, send_file, Blueprint, current_app
bp = Blueprint("thumbnails", __name__)
@@ -31,7 +31,10 @@ def mkdir(path):
def resize_and_crop(img_path, modified_path, size):
- img = Image.open(img_path)
+ try:
+ img = Image.open(img_path)
+ except FileNotFoundError:
+ abort(404)
# Get current and desired ratio for the images
img_ratio = img.size[0] / float(img.size[1])