diff --git a/app/__init__.py b/app/__init__.py deleted file mode 100644 index f83a545..0000000 --- a/app/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask import Flask -from flask_bootstrap import Bootstrap -from config import Config - -app = Flask(__name__) -Bootstrap(app) -app.config.from_object(Config) - -from app import routes diff --git a/app/forms.py b/app/forms.py deleted file mode 100644 index 39e2a49..0000000 --- a/app/forms.py +++ /dev/null @@ -1,8 +0,0 @@ -from flask_wtf import FlaskForm -from wtforms import DateTimeField, DecimalField, SubmitField -from wtforms.validators import DataRequired - -class DownloadForm(FlaskForm): - start_time = DateTimeField('Start time', validators=[DataRequired()]) - length = DecimalField('Length', validators=[DataRequired()]) - submit = SubmitField('Download') diff --git a/app/routes.py b/app/routes.py deleted file mode 100644 index 0798c48..0000000 --- a/app/routes.py +++ /dev/null @@ -1,21 +0,0 @@ -from flask import render_template, flash, redirect, url_for, request, send_from_directory -from app import app -from app.forms import DownloadForm -from datetime import datetime, timedelta - -@app.route('/', methods=['GET', 'POST']) -def download(): - form = DownloadForm() - if request.method == 'GET': - form.start_time.data = datetime.now() - timedelta(hours = 1) - form.length.data = 60 - elif form.validate_on_submit(): - flash('The download should start immediately.') - return render_template('download.html', form=form, filename='test.mp3') - else: - flash('Error') - return render_template('download.html', form=form) - -@app.route('/download_file/') -def download_file(filename): - return send_from_directory(app.config['DATA_DIR'], filename, as_attachment=True) diff --git a/prolefeeder.py b/prolefeeder.py index 357912d..a70dece 100644 --- a/prolefeeder.py +++ b/prolefeeder.py @@ -1,4 +1,45 @@ -from app import app +from flask import (Flask, render_template, flash, redirect, + url_for, request, send_from_directory) +from flask_bootstrap import Bootstrap +from flask_wtf import FlaskForm +from wtforms import DateTimeField, DecimalField, SubmitField +from wtforms.validators import DataRequired + +from datetime import datetime, timedelta + +from config import Config + + +app = Flask(__name__) +app.config.from_object(Config) +Bootstrap(app) + + +class DownloadForm(FlaskForm): + start_time = DateTimeField('Start time', validators=[DataRequired()]) + length = DecimalField('Length', validators=[DataRequired()]) + submit = SubmitField('Download') + + +@app.route('/', methods=['GET', 'POST']) +def download(): + form = DownloadForm() + if request.method == 'GET': + form.start_time.data = datetime.now() - timedelta(hours=1) + form.length.data = 60 + elif form.validate_on_submit(): + flash('The download should start immediately.') + return render_template('download.html', form=form, filename='test.mp3') + else: + flash('Error') + return render_template('download.html', form=form) + + +@app.route('/download_file/') +def download_file(filename): + return send_from_directory(app.config['DATA_DIR'], filename, + as_attachment=True) + if __name__ == '__main__': app.run(debug=True) diff --git a/app/templates/base.html b/templates/base.html similarity index 100% rename from app/templates/base.html rename to templates/base.html diff --git a/app/templates/download.html b/templates/download.html similarity index 100% rename from app/templates/download.html rename to templates/download.html