diff options
author | John Nduli | 2024-08-26 20:40:49 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-08-29 15:34:44 +0300 |
commit | c33cfc004e3b7f3e1dc52d3e89c785a175edd0d6 (patch) | |
tree | 07c0deaa9c0f4ef730a9b90a28c770288e5608bf /gn3/api | |
parent | 27fcbb90f9b1b059aef8dce3cdb1f42150bfafda (diff) | |
download | genenetwork3-c33cfc004e3b7f3e1dc52d3e89c785a175edd0d6.tar.gz |
feat: add api calls to get categories and last comment
Diffstat (limited to 'gn3/api')
-rw-r--r-- | gn3/api/metadata_api/wiki.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py index 1e566cd..32872f3 100644 --- a/gn3/api/metadata_api/wiki.py +++ b/gn3/api/metadata_api/wiki.py @@ -85,3 +85,28 @@ def get_wiki_entries(symbol: str): payload.headers["Content-Type"] = "application/ld+json" return payload, status_code return jsonify(data), status_code + + +@wiki_blueprint.route("/<int:comment_id>", methods=["GET"]) +def get_wiki(comment_id: int): + with db_utils.database_connection(current_app.config["SQL_URI"]) as conn: + return jsonify(wiki.get_latest_comment(conn, comment_id)) + return jsonify(error="Error editting wiki entry, most likely due to DB error!"), 500 + + +@wiki_blueprint.route("/categories", methods=["GET"]) +def get_categories(): + with db_utils.database_connection(current_app.config["SQL_URI"]) as conn: + cursor = conn.cursor() + categories_dict = wiki.get_categories(cursor) + return jsonify(categories_dict) + return jsonify(error="Error editting wiki entry, most likely due to DB error!"), 500 + + +@wiki_blueprint.route("/species", methods=["GET"]) +def get_species(): + with db_utils.database_connection(current_app.config["SQL_URI"]) as conn: + cursor = conn.cursor() + species_dict = wiki.get_species(cursor) + return jsonify(species_dict) + return jsonify(error="Error editting wiki entry, most likely due to DB error!"), 500 |