1818__all__ = ('endpoint' )
1919
2020endpoint = Blueprint ('endpoint' , __name__ )
21-
2221resultSetMimetypesDefault = 'application/sparql-results+xml'
2322askMimetypesDefault = 'application/sparql-results+xml'
2423rdfMimetypesDefault = 'text/turtle'
3029 'application/sparql-results+json' , 'application/json' , 'text/html' ,
3130 'application/xhtml+xml' ]
3231rdfMimetypes = ['text/turtle' , 'application/x-turtle' , 'application/rdf+xml' , 'application/xml' ,
33- 'application/n-triples' , 'application/trig' ]
34-
35- serializations = {
36- 'text/turtle' : 'turtle' ,
37- 'application/x-turtle' : 'turtle' ,
38- 'text/csv' : 'csv' ,
39- 'text/html' : 'html' ,
40- 'application/xhtml+xml' : 'html' ,
41- 'application/sparql-results+xml' : 'xml' ,
42- 'application/xml' : 'xml' ,
43- 'application/rdf+xml' : 'xml' ,
44- 'application/sparql-results+json' : 'json' ,
45- 'application/json' : 'json' ,
46- 'application/n-triples' : 'nt' ,
47- 'application/trig' : 'trig'
48- }
32+ 'application/n-triples' , 'application/trig' , 'application/ld+json' ,
33+ 'application/json' ]
4934
5035
5136@endpoint .route ("/sparql" , defaults = {'branch_or_ref' : None }, methods = ['POST' , 'GET' ])
@@ -183,7 +168,7 @@ def sparql(branch_or_ref):
183168 if not mimetype :
184169 return make_response ("Mimetype: {} not acceptable" .format (mimetype ), 406 )
185170
186- response = create_result_response (res , mimetype , serializations [ mimetype ] )
171+ response = create_result_response (res , mimetype )
187172 if branch_or_ref :
188173 response .headers ["X-CurrentBranch" ] = branch_or_ref
189174 if commitid :
@@ -234,7 +219,7 @@ def provenance():
234219 if not mimetype :
235220 return make_response ("Mimetype: {} not acceptable" .format (mimetype ), 406 )
236221
237- return create_result_response (res , mimetype , serializations [ mimetype ] )
222+ return create_result_response (res , mimetype )
238223 else :
239224 if request .accept_mimetypes .best_match (['text/html' ]) == 'text/html' :
240225 return render_template ('sparql.html' , mode = 'provenance' )
@@ -260,9 +245,9 @@ def _getBestMatchingMimeType(request, queryType):
260245 return mimetype
261246
262247
263- def create_result_response (res , mimetype , serialization ):
248+ def create_result_response (res , mimetype ):
264249 """Create a response with the requested serialization."""
265- response = make_response (res .serialize (format = serialization ), 200 )
250+ response = make_response (res .serialize (format = mimetype ), 200 )
266251 response .headers ['Content-Type' ] = mimetype
267252 return response
268253
0 commit comments