Skip to content

Commit

Permalink
Add CORS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
epoz committed Nov 26, 2024
1 parent 1030a60 commit 6c9c803
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/shmarql/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ def shmarql_get(
if format == "turtle":
return Response(
results["data"],
headers={"Content-Type": "text/turtle"},
headers={
"Content-Type": "text/turtle",
"Access-Control-Allow-Origin": "*",
},
)
try:
# if format is not turtle, but the results are bytes, try to parse it and return as json
Expand All @@ -343,6 +346,7 @@ def shmarql_get(
headers={
"Content-Type": "application/sparql-results+xml",
"Content-Disposition": f"attachment; filename={hash_query(query)}.xml",
"Access-Control-Allow-Origin": "*",
},
)

Expand All @@ -354,6 +358,7 @@ def shmarql_get(
headers={
"Content-Type": "text/csv",
"Content-Disposition": f"attachment; filename={hash_query(query)}.csv",
"Access-Control-Allow-Origin": "*",
},
)
if format == "json":
Expand All @@ -363,6 +368,7 @@ def shmarql_get(
json.dumps(results, indent=2),
headers={
"Content-Type": "application/sparql-results+json",
"Access-Control-Allow-Origin": "*",
},
)

Expand Down

0 comments on commit 6c9c803

Please sign in to comment.