aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/metadata_api
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-08-26 15:27:33 +0300
committerBonfaceKilz2024-08-26 15:35:33 +0300
commitbf4d04edec08ae437d0cecc533266d50ecb711af (patch)
tree559249dbb1dbedf5821e8ccf6a17dccf39ebe0a5 /gn3/api/metadata_api
parentc92d7b2f3a82173846a7a288e4b40edb5444553e (diff)
downloadgenenetwork3-bf4d04edec08ae437d0cecc533266d50ecb711af.tar.gz
Move "GET /wiki/<symbol>" end-point to gn3.api.metadata.wiki.
* gn3/api/metadata.py (get_wiki_entries): Move this... * gn3/api/metadata_api/wiki.py (edit_wiki): ... here. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api/metadata_api')
-rw-r--r--gn3/api/metadata_api/wiki.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py
index 621960e..c84578a 100644
--- a/gn3/api/metadata_api/wiki.py
+++ b/gn3/api/metadata_api/wiki.py
@@ -2,9 +2,11 @@
import datetime
from typing import Any, Dict
-from flask import Blueprint, request, jsonify, current_app
+from flask import Blueprint, request, jsonify, current_app, make_response
from gn3 import db_utils
from gn3.db import wiki
+from gn3.db.rdf import (query_frame_and_compact,
+ get_wiki_entries_by_symbol)
wiki_blueprint = Blueprint("wiki", __name__, url_prefix="wiki")
@@ -64,3 +66,22 @@ def edit_wiki(comment_id: int):
)
return jsonify({"success": "ok"})
return jsonify(error="Error editting wiki entry, most likely due to DB error!"), 500
+
+
+@wiki_blueprint.route("/<string:symbol>", methods=["GET"])
+def get_wiki_entries(symbol: str):
+ """Fetch wiki entries"""
+ content_type = request.headers.get("Content-Type")
+ status_code = 200
+ response = get_wiki_entries_by_symbol(
+ symbol=symbol,
+ sparql_uri=current_app.config.get("SPARQL_ENDPOINT"))
+ data = response.get("data")
+ if not data:
+ data = {}
+ status_code = 404
+ if content_type == "application/ld+json":
+ response = make_response(response)
+ response.headers["Content-Type"] = "application/ld+json"
+ return response, status_code
+ return jsonify(data), status_code