Skip to content

Commit

Permalink
Fix common error
Browse files Browse the repository at this point in the history
  • Loading branch information
XMB5 committed Sep 25, 2024
1 parent da6f251 commit 8368241
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions donut/modules/directory_search/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import flask
import json
import mimetypes

import werkzeug.exceptions
from flask import jsonify, redirect

from donut.auth_utils import get_user_id, is_caltech_user, login_redirect
Expand Down Expand Up @@ -73,9 +75,14 @@ def search():
per_page = 10
else:
form = flask.request.args
page = int(form['page'])
total = int(form['total'])
per_page = int(form['per_page'])
try:
page = int(form['page'])
total = int(form['total'])
per_page = int(form['per_page'])
except werkzeug.exceptions.BadRequestKeyError:
# happens all the time for some reason, perhaps web scraping bots trying to paginate?
# instead redirect user back to search page
return flask.redirect('/directory')
name = form['name']
if name.strip() == '':
name = None
Expand Down

0 comments on commit 8368241

Please sign in to comment.