From 754f4037ca5ddd5055f916981e04d393c6c9deed Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 11 Nov 2018 15:15:43 +0100 Subject: [PATCH] call prepare_download() to prepare a download --- prolefeeder.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/prolefeeder.py b/prolefeeder.py index d7d0420..e398495 100644 --- a/prolefeeder.py +++ b/prolefeeder.py @@ -29,10 +29,14 @@ def download(): form.start_time.data = datetime.now() - timedelta(hours=1) form.length.data = 60 elif form.validate_on_submit(): - flash('The download should start immediately.', 'success') - return render_template('download.html', form=form, filename='test.mp3') + output_filename = prepare_download(form) + if output_filename: + flash('The download should start immediately.', 'success') + return render_template('download.html', form=form, filename=output_filename) + else: + flash('Error preparing download!', 'warning') else: - flash('Error', 'warning') + flash('Error in form!', 'warning') return render_template('download.html', form=form) @@ -42,5 +46,9 @@ def download_file(filename): as_attachment=True) +def prepare_download(form): + return 'test.mp3' + + if __name__ == '__main__': app.run(debug=True)