serve file from the download form

stable
neingeist 6 years ago
parent e340e967a6
commit 64772b13ba

@ -12,11 +12,11 @@ def index():
def download(): def download():
form = DownloadForm() form = DownloadForm()
if form.validate_on_submit(): if form.validate_on_submit():
return render_template('download_thanks.html', title='Download', form=form) return render_template('download.html', form=form, filename='test.mp3')
elif request.method == 'GET': elif request.method == 'GET':
form.date.data = datetime.now() - timedelta(hours = 1) form.date.data = datetime.now() - timedelta(hours = 1)
form.length.data = 60 form.length.data = 60
return render_template('download.html', title='Download', form=form) return render_template('download.html', form=form)
@app.route('/download_file/<path:filename>') @app.route('/download_file/<path:filename>')
def download_file(filename): def download_file(filename):

@ -1,5 +1,13 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block head %}
{{ super() }}
{% if filename is defined %}
<meta http-equiv="refresh" content="0;URL='download_file/{{ filename }}'" />
{% endif %}
{% endblock %}
{% block app_content %} {% block app_content %}
<h1>Download</h1> <h1>Download</h1>
<form action="" method="post" novalidate> <form action="" method="post" novalidate>

@ -1,10 +0,0 @@
{% extends "base.html" %}
{% block head %}
{{ super() }}
<meta http-equiv="refresh" content="0;URL='download_file/test.mp3'" />
{% endblock %}
{% block app_content %}
<h1>Thanks!</h1>
{% endblock %}
Loading…
Cancel
Save