Verified Commit a15ed101 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add 404 fallback

parent 78ca8b66
Loading
Loading
Loading
Loading
+12 −0
Changes for portal/api/rest.py: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
from flask import render_template

from .blueprint import bp
from ..problem_details import not_found


@bp.get("/<path:_>")
def fallback_not_found(_):
    """
    If you can't find a matching API endpoint, fallback to returning a 404.

    We completely ignore the provided path (hence the argument name "_" and not something useful),
    because if this method is ever reached, we already know the only viable response is a 404.
    """
    return not_found()


@bp.get("/")