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 ++++--- templates/index.html | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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) diff --git a/templates/index.html b/templates/index.html index cb91326..834cec9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,8 +10,8 @@
 this website pulls a random arXiv publication for a given category
 source code
-all categories: here
-examples:
+taxonomy: here
+categories:
 {% for i in taxonomy %}
   {{ i }}
 {% endfor %}
-- 
cgit 1.4.1