You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
826 B
Python

from flask import render_template, flash, redirect, url_for, request, send_from_directory
6 years ago
from app import app
from app.forms import DownloadForm
from datetime import datetime, timedelta
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/download', methods=['GET', 'POST'])
def download():
form = DownloadForm()
if form.validate_on_submit():
return render_template('download.html', form=form, filename='test.mp3')
6 years ago
elif request.method == 'GET':
form.date.data = datetime.now() - timedelta(hours = 1)
form.length.data = 60
return render_template('download.html', form=form)
@app.route('/download_file/<path:filename>')
def download_file(filename):
return send_from_directory(app.config['DATA_DIR'], filename, as_attachment=True)