call prepare_download() to prepare a download
This commit is contained in:
		
							parent
							
								
									4db9d9f333
								
							
						
					
					
						commit
						754f4037ca
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		| 
						 | 
					@ -29,10 +29,14 @@ def download():
 | 
				
			||||||
        form.start_time.data = datetime.now() - timedelta(hours=1)
 | 
					        form.start_time.data = datetime.now() - timedelta(hours=1)
 | 
				
			||||||
        form.length.data = 60
 | 
					        form.length.data = 60
 | 
				
			||||||
    elif form.validate_on_submit():
 | 
					    elif form.validate_on_submit():
 | 
				
			||||||
        flash('The download should start immediately.', 'success')
 | 
					        output_filename = prepare_download(form)
 | 
				
			||||||
        return render_template('download.html', form=form, filename='test.mp3')
 | 
					        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:
 | 
					    else:
 | 
				
			||||||
        flash('Error', 'warning')
 | 
					        flash('Error in form!', 'warning')
 | 
				
			||||||
    return render_template('download.html', form=form)
 | 
					    return render_template('download.html', form=form)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,5 +46,9 @@ def download_file(filename):
 | 
				
			||||||
                               as_attachment=True)
 | 
					                               as_attachment=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def prepare_download(form):
 | 
				
			||||||
 | 
					    return 'test.mp3'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    app.run(debug=True)
 | 
					    app.run(debug=True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue