404 and max size on hearings
This commit is contained in:
parent
8f7c857c0c
commit
6780b4d638
@ -2,7 +2,7 @@ import httpx
|
|||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
from . import app
|
from . import app
|
||||||
from flask import request
|
from flask import request, abort
|
||||||
|
|
||||||
BASE_API_URL = "https://scrapple.fly.io/hearings/house/118/"
|
BASE_API_URL = "https://scrapple.fly.io/hearings/house/118/"
|
||||||
BASE_DIR = pathlib.Path("data/congress-hearing-118-house")
|
BASE_DIR = pathlib.Path("data/congress-hearing-118-house")
|
||||||
@ -34,8 +34,10 @@ def shortened(hearing):
|
|||||||
@app.route("/hearings")
|
@app.route("/hearings")
|
||||||
def hearings_list():
|
def hearings_list():
|
||||||
offset = int(request.args.get("offset", 0))
|
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")
|
format = request.args.get("format", "json")
|
||||||
|
if offset < 0:
|
||||||
|
abort(404)
|
||||||
if offset + limit > len(ALL_HEARINGS):
|
if offset + limit > len(ALL_HEARINGS):
|
||||||
next_url = None
|
next_url = None
|
||||||
else:
|
else:
|
||||||
@ -60,4 +62,6 @@ def hearings_list():
|
|||||||
|
|
||||||
@app.route("/hearings/<jacket_id>")
|
@app.route("/hearings/<jacket_id>")
|
||||||
def hearings_detail(jacket_id):
|
def hearings_detail(jacket_id):
|
||||||
|
if jacket_id not in ALL_HEARINGS:
|
||||||
|
abort(404)
|
||||||
return ALL_HEARINGS[jacket_id]
|
return ALL_HEARINGS[jacket_id]
|
||||||
|
Loading…
Reference in New Issue
Block a user