diff options
-rw-r--r-- | app.py | 7 | ||||
-rw-r--r-- | 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('/<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) 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 @@ <pre> this website pulls a random arXiv publication for a given category <a href="https://git.tzlil.net/arXiv.git" title="if you're wondering why my code needs to scrape arXiv and build probability distributions see fuck you.py">source code</a> -all categories: <a href="https://arxiv.org/category_taxonomy">here</a> -examples: +taxonomy: <a href="https://arxiv.org/category_taxonomy">here</a> +categories: {% for i in taxonomy %} <a href='{{ i }}'>{{ i }}</a> {% endfor %} |