From 33f6c91233f46cf313f2d03746823a48f7500164 Mon Sep 17 00:00:00 2001 From: zPlus Date: Thu, 20 Jun 2024 10:55:44 +0200 Subject: [PATCH] Add FUSEKI_ENDPOINT environment variable. The URI to the Fuseki endpoint was hard coded, so it's been moved to an environment variable. --- app.py | 8 +++++++- website.service | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 7e7062c..8c94ea8 100755 --- a/app.py +++ b/app.py @@ -5,6 +5,7 @@ import datetime import dateutil import functools import jinja2 +import os import pathlib import pyld import re @@ -13,6 +14,11 @@ import requests from bottle import jinja2_template as template, request, response from string import Template +# Check that we have an endpoint for querying +FUSEKI_ENDPOINT = os.environ.get('FUSEKI_ENDPOINT') +if not FUSEKI_ENDPOINT: + raise Exception('FUSEKI_ENDPOINT environment variable not set.') + # This only exists for exporting the bottle app object for a WSGI server such as Gunicorn application = bottle.app() @@ -26,7 +32,7 @@ def query(query_string, jsonld_frame=None): """ http_request = requests.post( - 'http://localhost:3030/dokk?default-graph-uri=urn:x-arq:UnionGraph', + FUSEKI_ENDPOINT, data = { 'format': 'json', 'query': query_string}) results = http_request.json() diff --git a/website.service b/website.service index 0586f33..5c52480 100644 --- a/website.service +++ b/website.service @@ -11,6 +11,9 @@ Description=DOKK website app After=network.target [Service] +# URI to Fuseki endpoint for querying +Environment=FUSEKI_ENDPOINT=https://example.org:3030/dokk + ExecStart=/home/fuseki/dokk.org/venv/bin/gunicorn --bind localhost:8080 app:application User=fuseki