import requests #Required library: #https://pypi.org/project/requests/ #pip install requests # helper function to raise exception if the REST endpoint returns an # unexpected status code def assert_status(response, expected_status, message): if response.status_code != expected_status: raise Exception( message + "\nStatus received={}\n{}".format(response.status_code, response.text)) #rdfox_server = "http://158.39.75.55:8081" rdfox_server = "http://sirius-geo-annotator.uiocloud.no:8081" # List datastores response = requests.get(rdfox_server + "/datastores") assert_status(response, requests.codes.ok, "Failed to obtain list of datastores") print("== Datastore list ==\n", response.text) # Select query sparql_text = "prefix : " \ "prefix ann: " \ "select ?p where { ?p a ann:GeologicalCrossSection }" response = requests.get( rdfox_server + "/datastores/SiriusGIAnn/sparql", params={"query": sparql_text}) assert_status(response, requests.codes.ok, "Failed to run select query.") print("== Initial query result ==\n", response.text)