import flask
from owlready2 import *
from owlready2.sparql.endpoint import *
# Load one or more ontologies
go = get_ontology("
http://localhost:8000/repositories/semantic").load()
app = flask.Flask("Owlready_sparql_endpoint")
endpoint = EndPoint(default_world)
app.route("/sparql", methods = ["GET"])(endpoint)
import werkzeug.serving
werkzeug.serving.run_simple("localhost", 5008, app)
I am getting errors when loading the localhost SPARQL endpoint of Graph DB.
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Traceback (most recent call last):
File "/home/gaurav/.local/lib/python3.8/site-packages/owlready2/namespace.py", line 899, in load
try: fileobj = urllib.request.urlopen(url or f)
File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "localqueries.py", line 17, in <module>
go = get_ontology("
http://gaurav-HP-Notebook:8000/repositories/semantic").load() # (~ 170 Mb), can take a moment!
File "/home/gaurav/.local/lib/python3.8/site-packages/owlready2/namespace.py", line 900, in load
except: raise OwlReadyOntologyParsingError("Cannot download '%s'!" % f)
Please tell me what wrong I am doing, or there is another way of doing the same.
I got this link (
http://gaurav-HP-Notebook:8000/repositories/semantic) from Graph DB SE version, setup->repositories, and copied the link.
My intention was to connect to Ontologies imported in the localhost Graph DB server and query through python using owlready2 API.