some cleanup and refactoring

This commit is contained in:
Finn Christiansen 2018-12-30 09:24:29 +01:00
parent 0c4fed2a2b
commit fcd783ef26
7 changed files with 32 additions and 9 deletions

View file

@ -21,6 +21,8 @@
ErrorLog ${APACHE_LOG_DIR}/reminder.pimux.de_error.log
CustomLog ${APACHE_LOG_DIR}/reminder.pimux.de_access.log combined
SetEnv SECRET_KEY secret
WSGIDaemonProcess reminder user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/vhosts/reminder.pimux.de/index.py
WSGIScriptReloading On

13
app/__init__.py Normal file
View file

@ -0,0 +1,13 @@
from flask import Flask
from flask_wtf.csrf import CSRFProtect
from app.index import index
cp = CSRFProtect()
def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'SECRET_KEY'
app.register_blueprint(index)
cp.init_app(app)
return app

BIN
app/__init__.pyc Normal file

Binary file not shown.

View file

@ -1,17 +1,15 @@
from flask import Flask, render_template, request, send_file
from flask import Blueprint, render_template, send_file
from icalendar import Calendar, Alarm
from flask_wtf import FlaskForm
#from flask_wtf.file import FileField, FileRequired
from wtforms import FileField, IntegerField, SubmitField
from wtforms.validators import InputRequired
from flask_wtf.file import FileField, FileRequired
from wtforms import IntegerField, SubmitField
from wtforms.widgets.html5 import NumberInput
import tempfile
application = Flask(__name__)
application.config['SECRET_KEY'] = 'secret'
index = Blueprint('index', __name__, template_folder='templates')
@application.route("/", methods=['GET', 'POST'])
@index.route("/", methods=['GET', 'POST'])
def addreminder():
form = IcsForm()
content = render_template('index.html', form=form)
@ -49,7 +47,7 @@ def addreminder():
class IcsForm(FlaskForm):
icsfile = FileField('ICS File', validators=[InputRequired()])
icsfile = FileField('ICS File', validators=[FileRequired()])
hours = IntegerField('Hours', default=0,
widget=NumberInput(step=1, min=0, max=24))
minutes = IntegerField('Minutes', default=0,

View file

@ -14,7 +14,7 @@
{% endblock %}
</main>
<footer>
<a href="https://github.com/Finn10111/caesar-chiffre">source code on github</a>
<a href="https://github.com/Finn10111/reminder">source code on github</a>
</footer>
</body>
</html>

View file

@ -3,6 +3,7 @@
<h1>Add reminders to ICS files</h1>
<form method="POST" action="/" enctype=multipart/form-data>
<div class="form">
{{ form.csrf_token }}
<ol>
<li>Select ICS file</li>
<li>Set reminder time</li>

9
reminder.wsgi Normal file
View file

@ -0,0 +1,9 @@
import os
import sys
sys.path.insert(1, os.path.dirname(__file__))
from app import create_app
def application(environ, start_response):
os.environ['SECRET_KEY'] = environ.get('SECRET_KEY')
app = create_app()
return app(environ, start_response)