summary refs log tree commit diff
path: root/app.py
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-09-09 01:59:59 +0300
committertzlil <tzlils@protonmail.com>2023-09-09 01:59:59 +0300
commita7cafdeeb5624fbac2296861e491681f6b862dd7 (patch)
tree4d44ee45fb09bfa6e3b9b8153df68b4532c54fd1 /app.py
parentd09927ca6f7af2404e9c3a09a6e99dfdd1e87577 (diff)
whitelist categories
Diffstat (limited to 'app.py')
-rw-r--r--app.py7
1 files changed, 4 insertions, 3 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('/<topic>', 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)