Browse Source

contextualized download

kora 1 year ago
parent
commit
bc0a896dcc
2 changed files with 3 additions and 3 deletions
  1. 1 1
      app.py
  2. 2 2
      templates/index.html.j2

+ 1 - 1
app.py

@@ -50,7 +50,7 @@ def main():
         except:
             return redirect(url_for('error', message='no CSV data, or CSV input file missing required data'))
 
-        return redirect(url_for('main', download=outFileName))
+        return redirect(url_for('main', downloadFile=outFileName, downloadUrl=url_for('download')))
 
     return render_template('index.html.j2', data=formFields)
 

+ 2 - 2
templates/index.html.j2

@@ -37,10 +37,10 @@
 
   <script>
     const params = new URLSearchParams(window.location.search);
-    const downloadName = params.get('download');
+    const downloadName = params.get('downloadFile');
     if(downloadName){
       document.getElementById("fileForm").reset()
-      $.get('/download', { filename: downloadName }).done(function(data){
+      $.get(params.get('downloadUrl'), { filename: downloadName }).done(function(data){
         let link = document.createElement('a');
         link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(data);
         link.download = downloadName;