diff --git a/scrapple/hearings.py b/scrapple/hearings.py index 527aff4..b6dfc5e 100644 --- a/scrapple/hearings.py +++ b/scrapple/hearings.py @@ -2,7 +2,7 @@ import httpx import json import pathlib from . import app -from flask import request +from flask import request, abort BASE_API_URL = "https://scrapple.fly.io/hearings/house/118/" BASE_DIR = pathlib.Path("data/congress-hearing-118-house") @@ -34,8 +34,10 @@ def shortened(hearing): @app.route("/hearings") def hearings_list(): offset = int(request.args.get("offset", 0)) - limit = int(request.args.get("limit", 50)) + limit = min(int(request.args.get("limit", 50)), 200) format = request.args.get("format", "json") + if offset < 0: + abort(404) if offset + limit > len(ALL_HEARINGS): next_url = None else: @@ -60,4 +62,6 @@ def hearings_list(): @app.route("/hearings/") def hearings_detail(jacket_id): + if jacket_id not in ALL_HEARINGS: + abort(404) return ALL_HEARINGS[jacket_id]