initial commit
commit
5358ea95d6
@ -0,0 +1 @@
|
||||
__pycache__/
|
@ -0,0 +1,7 @@
|
||||
from flask import Flask
|
||||
from config import Config
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
|
||||
from app import routes
|
@ -0,0 +1,8 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import DateTimeField, DecimalField, SubmitField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
class DownloadForm(FlaskForm):
|
||||
date = DateTimeField('Date', validators=[DataRequired()])
|
||||
length = DecimalField('Length', validators=[DataRequired()])
|
||||
submit = SubmitField('Download')
|
@ -0,0 +1,21 @@
|
||||
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)
|
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Prolefeeder</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<a href="{{ url_for('index') }}">Home</a>
|
||||
<a href="{{ url_for('download') }}">Download</a>
|
||||
</div>
|
||||
<hr>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,23 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Download</h1>
|
||||
<form action="" method="post" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.date.label }}<br>
|
||||
{{ form.date() }}<br>
|
||||
{% for error in form.date.errors %}
|
||||
<span style="color: red;">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
{{ form.length.label }}<br>
|
||||
{{ form.length() }}<br>
|
||||
{% for error in form.length.errors %}
|
||||
<span style="color: red;">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
{% endblock %}
|
@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Hello!</h1>
|
||||
{% endblock %}
|
@ -0,0 +1 @@
|
||||
from app import app
|
@ -0,0 +1,3 @@
|
||||
flask
|
||||
flask-wtf
|
||||
python-dotenv
|
Loading…
Reference in New Issue