From 3eba9b8c2c3a1736549cbe6f5dfcb8fd05da62ab Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 21 Sep 2014 05:22:56 -0700 Subject: [PATCH] nmhive.py: Add GET /tags We don't want bookmarklet users adding random tags. Instead, restrict them to tags that are already in the database, which allows us to keep a consistent tag-set and present a simpler UI. The hard-coded _AVAILABLE_TAGS will be replaced by a notmuch query once I finish with the UI. --- nmhive.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nmhive.py b/nmhive.py index 08c61fc..363a1b8 100755 --- a/nmhive.py +++ b/nmhive.py @@ -13,9 +13,22 @@ app = flask.Flask(__name__) flask_cors.CORS(app) +_AVAILABLE_TAGS = { + 'bug', + 'needs-review', + 'obsolete', + 'patch', + } _TAGS = {} +@app.route('/tags', methods=['GET']) +def tags(): + return flask.Response( + response=json.dumps(sorted(_AVAILABLE_TAGS)), + mimetype='application/json') + + @app.route('/mid/', methods=['GET', 'POST']) def message_id_tags(message_id): if flask.request.method == 'POST': -- 2.26.2