From 42a32637bb52414eaa26982baeafc33b38f5411e Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Aug 2024 20:14:17 +0100 Subject: [PATCH] Modifications --- backend/app.py | 3 --- content/data-downloads/singapore-srtm.md | 2 +- layouts/shortcodes/download-data.html | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/app.py b/backend/app.py index 0a3b779..8229f49 100644 --- a/backend/app.py +++ b/backend/app.py @@ -56,8 +56,5 @@ def download_file(filename): except FileNotFoundError: abort(404) -if __name__ == '__main__': - app.run(debug=True) - if __name__ == '__main__': app.run() diff --git a/content/data-downloads/singapore-srtm.md b/content/data-downloads/singapore-srtm.md index a94d0f8..fb9c1ae 100644 --- a/content/data-downloads/singapore-srtm.md +++ b/content/data-downloads/singapore-srtm.md @@ -11,7 +11,7 @@ tags: ["QGIS", "SRTM", "DEM", "Raster", "download"] {{< figure src="/pics/blog/batch-import-postgis-rasters/singapore-final.webp" width="300">}} Download the Digital Elevation Model featured in [this](/blog/batch-import-postgis-rasters/) blog. -{{< download-data src="http://api.baseddata.io/download/singapore-srtm-dem.tif" name="singapore-srtm-dem.tif" >}} +{{< download-data src="https://api.baseddata.io/download/singapore-srtm-dem.tif" name="singapore-srtm-dem.tif" >}} #### Citations NASA Shuttle Radar Topography Mission (SRTM)(2013). Shuttle Radar Topography Mission (SRTM) Global. Distributed by OpenTopography. https://doi.org/10.5069/G9445JDF. Accessed: 2024-08-06 diff --git a/layouts/shortcodes/download-data.html b/layouts/shortcodes/download-data.html index afdb618..84457f3 100644 --- a/layouts/shortcodes/download-data.html +++ b/layouts/shortcodes/download-data.html @@ -6,6 +6,9 @@ async function downloadFile(url, name) { try { const response = await fetch(url); + if (!response.ok) { + throw new Error('Network response was not ok'); + } const blob = await response.blob(); const link = document.createElement('a'); link.href = URL.createObjectURL(blob); @@ -13,6 +16,7 @@ document.body.appendChild(link); link.click(); document.body.removeChild(link); + URL.revokeObjectURL(link.href); // Clean up the object URL } catch (error) { console.error('Error downloading the file:', error); }