From b2acff1955cd2c95382624a2faf5731874a0c54b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 6 Jan 2022 19:09:38 +0100 Subject: Return 404 if study is not found --- app/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 1934c23..8ca26bc 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,7 @@ import os, sys from flask import Blueprint, render_template, request, flash, redirect,\ - url_for, current_app, g + url_for, current_app, g, abort from werkzeug.utils import secure_filename from wtforms.validators import ValidationError from .backend import Storage @@ -76,7 +76,11 @@ def upload(study, course = None): @main.route('//courses/') def courses_show(study, course = None): """ Lists all courses or exams for a course """ - backend = get_studies()[study] + studies = get_studies() + if study not in studies: + abort(404) + + backend = studies[study] if course: entries = sorted(backend.get_exams(course), reverse = True) return render_template('exams.html', study = study, course = course, -- cgit v1.2.3-1-g7c22