From 236d9236c794d7870258eab9e087f990c557462a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 26 May 2022 16:42:27 +0300 Subject: Add Endpoint to get menu items for use in UI --- gn3/api/menu.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 gn3/api/menu.py (limited to 'gn3/api') diff --git a/gn3/api/menu.py b/gn3/api/menu.py new file mode 100644 index 0000000..cc77ab8 --- /dev/null +++ b/gn3/api/menu.py @@ -0,0 +1,14 @@ +"""API for data used to generate menus""" + +from flask import jsonify, Blueprint + +from gn3.db.menu import gen_dropdown_json +from gn3.db_utils import database_connector + +menu = Blueprint("menu", __name__) + +@menu.route("/generate/json") +def generate_json(): + """Get the menu in the JSON format""" + with database_connector() as conn: + return jsonify(gen_dropdown_json(conn)) -- cgit v1.2.3