From 3d82671bd350681c62b53125b887b01543e8ad7c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 18 Mar 2019 14:52:22 -0700 Subject: some API-like routes are unstable --- python/fatcat_web/routes.py | 35 ++++++++++++++++++---------------- python/fatcat_web/templates/stats.html | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'python') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 7a254f52..d660da86 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -119,16 +119,6 @@ def creator_history(ident): entity=entity, history=history) -@app.route('/container/issnl//stats.json', methods=['GET', 'OPTIONS']) -@crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type']) -def container_issnl_stats(issnl): - try: - stats = get_elastic_container_stats(issnl) - except Exception as ae: - print(ae) - abort(503) - return jsonify(stats) - @app.route('/creator//edit', methods=['GET']) def creator_edit_view(ident): try: @@ -505,7 +495,19 @@ def get_changelog_stats(): }} return stats -@app.route('/stats.json', methods=['GET', 'OPTIONS']) +@app.route('/stats', methods=['GET']) +def stats_page(): + try: + stats = get_elastic_entity_stats() + stats.update(get_changelog_stats()) + except Exception as ae: + print(ae) + abort(503) + return render_template('stats.html', stats=stats) + +### Pseudo-APIs ############################################################# + +@app.route('/unstable/stats.json', methods=['GET', 'OPTIONS']) @crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type']) def stats_json(): try: @@ -516,15 +518,16 @@ def stats_json(): abort(503) return jsonify(stats) -@app.route('/stats', methods=['GET']) -def stats_page(): +@app.route('/unstable/container/issnl//stats.json', methods=['GET', 'OPTIONS']) +@app.route('/container/issnl//stats.json', methods=['GET', 'OPTIONS']) +@crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type']) +def container_issnl_stats(issnl): try: - stats = get_elastic_entity_stats() - stats.update(get_changelog_stats()) + stats = get_elastic_container_stats(issnl) except Exception as ae: print(ae) abort(503) - return render_template('stats.html', stats=stats) + return jsonify(stats) ### Auth #################################################################### diff --git a/python/fatcat_web/templates/stats.html b/python/fatcat_web/templates/stats.html index f11ca820..7f56248f 100644 --- a/python/fatcat_web/templates/stats.html +++ b/python/fatcat_web/templates/stats.html @@ -3,7 +3,7 @@

Stats

-You can also fetch these numbers as JSON. +You can also fetch these numbers as JSON.

Changelog

-- cgit v1.2.3