from flask import render_template, flash, redirect, url_for, request 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(): flash('Download requested: {}, length={}'.format( form.date.data, form.length.data)) return redirect(url_for('index')) elif request.method == 'GET': form.date.data = datetime.now() - timedelta(hours = 1) form.length.data = 60 return render_template('download.html', title='Download', form=form)