From 6780b4d638bb405fd36764a05ecc6b4477f4393f Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 10 Jan 2025 17:10:29 -0600 Subject: [PATCH] 404 and max size on hearings --- scrapple/hearings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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]