diff options
author | Munyoki Kilyungi | 2024-08-26 15:27:33 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-08-26 15:35:33 +0300 |
commit | bf4d04edec08ae437d0cecc533266d50ecb711af (patch) | |
tree | 559249dbb1dbedf5821e8ccf6a17dccf39ebe0a5 /gn3 | |
parent | c92d7b2f3a82173846a7a288e4b40edb5444553e (diff) | |
download | genenetwork3-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')
-rw-r--r-- | gn3/api/metadata.py | 25 | ||||
-rw-r--r-- | gn3/api/metadata_api/wiki.py | 23 |
2 files changed, 23 insertions, 25 deletions
diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py index 4ce32e0..3f28f5d 100644 --- a/gn3/api/metadata.py +++ b/gn3/api/metadata.py @@ -5,10 +5,7 @@ from string import Template from pathlib import Path from authlib.jose import jwt - from flask import Blueprint -from flask import jsonify -from flask import make_response from flask import request from flask import current_app @@ -17,8 +14,7 @@ from gn3.db.datasets import (retrieve_metadata, save_metadata, get_history) from gn3.db.rdf import (query_frame_and_compact, - query_and_compact, - get_wiki_entries_by_symbol) + query_and_compact) from gn3.db.constants import ( RDF_PREFIXES, BASE_CONTEXT, DATASET_CONTEXT, @@ -396,25 +392,6 @@ CONSTRUCT { ) -@metadata.route("/wiki/<symbol>", methods=["GET"]) -def get_wiki_entries(symbol): - """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 - - @metadata.route("/genewikis/ncbi/<symbol>", methods=["GET"]) def get_ncbi_genewiki_entries(symbol): """Fetch the NCBI GeneRIF entries""" 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 |