404 and max size on hearings

This commit is contained in:
James Turk 2025-01-10 17:10:29 -06:00
parent 8f7c857c0c
commit 6780b4d638

View File

@ -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/<jacket_id>")
def hearings_detail(jacket_id):
if jacket_id not in ALL_HEARINGS:
abort(404)
return ALL_HEARINGS[jacket_id]