--cors for /name.db downloads, refs #1057

This commit is contained in:
Simon Willison 2020-10-27 13:39:07 -07:00
commit c3aba4aa98
4 changed files with 19 additions and 5 deletions

View file

@ -144,10 +144,14 @@ class DatabaseDownload(DataView):
if not db.path:
raise DatasetteError("Cannot download database", status=404)
filepath = db.path
headers = {}
if self.ds.cors:
headers["Access-Control-Allow-Origin"] = "*"
return AsgiFileDownload(
filepath,
filename=os.path.basename(filepath),
content_type="application/octet-stream",
headers=headers,
)