From a7cafdeeb5624fbac2296861e491681f6b862dd7 Mon Sep 17 00:00:00 2001 From: tzlil Date: Sat, 9 Sep 2023 01:59:59 +0300 Subject: whitelist categories --- app.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index b910046..fe84158 100644 --- a/app.py +++ b/app.py @@ -56,9 +56,8 @@ def get_probability_distribution(topic): taxonomy = [ - 'cs', 'econ', 'eess', 'math', 'astro-ph', 'cond-mat', 'gr-qc', 'hep-ex', - 'hep-lat', 'hep-ph', 'hep-th', 'math-ph', 'nlin', 'nucl-ex', 'nucl-th', - 'physics', 'quant-ph', 'q-bio', 'q-fin', 'stat' + 'cs', 'math', 'physics', 'econ', 'eess', 'astro-ph', 'cond-mat', 'gr-qc', 'hep-ex', + 'hep-lat', 'hep-ph', 'hep-th', 'math-ph', 'nlin', 'nucl-ex', 'nucl-th', 'quant-ph', 'q-bio', 'q-fin', 'stat' ] app = Flask(__name__) @@ -71,6 +70,8 @@ def favicon(): @app.route('/', methods=['GET']) def random(topic): + if topic not in taxonomy: + return abort(500) l = get_links(topic) p = get_probability_distribution(topic) d = np.random.choice(l, p=p) -- cgit 1.4.1