SMTL

Die Stadtmeistersteilerliste und das Anmeldeformular - SK Langen e.V.
git clone git://git.oshgnacknak.de/SMTL.git
Log | Files | Refs | README

commit f3c19b2deef4cb56e17905da00a6bbb93b1ad4a8
parent a5afce2e2d06fb4d7cceb3443ce1a7986792d1ee
Author: Oshgnacknak <osh@oshgnacknak.de>
Date:   Thu, 27 Jun 2019 15:20:49 +0100

split run and app config

Diffstat:
Mconfig.py.dist | 15++++++++++-----
Mrun.py | 8++++----
Msmtl/app.py | 6+++---
Msmtl/templates/signup_form.html | 8++++----
4 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/config.py.dist b/config.py.dist @@ -1,11 +1,16 @@ -# create your config here and safe as 'config.py' -# 'SECRET_KEY' must be set. $ head -c 32 /dev/random | sha1sum -# the rest is optional +# Create your config here and safe as 'config.py'. +# Things in 'app_config' must all be set. ($ head -c 32 /dev/random | sha1sum) +# the 'run_config' is optional but has to be a dict. -config = { - 'SECRET_KEY': 'some_good_key', +app_config = { + 'SECRET_KEY': 'some_key', 'SQLALCHEMY_DATABASE_URI': 'sqlite:///../database.db', + 'RECAPTCHA_PUBLIC_KEY': 'some_other_key', + 'RECAPTCHA_PRIVATE_KEY': 'some_otherer_key' +} + +run_config = { 'DEBUG': False, 'HOST': '127.0.0.1', 'POST': 5000 diff --git a/run.py b/run.py @@ -1,14 +1,14 @@ from smtl.app import app from smtl.routes import routes -from config import config +from config import run_config import os def main(): app.register_blueprint(routes) - host = config.get('HOST', '127.0.0.1') - port = config.get('PORT', 5000) - debug = config.get('DEBUG', False) + host = run_config.get('HOST', '127.0.0.1') + port = run_config.get('PORT', 5000) + debug = run_config.get('DEBUG', False) app.run(host=host, port=port, debug=debug) diff --git a/smtl/app.py b/smtl/app.py @@ -1,15 +1,15 @@ from flask import Flask from flask_wtf.csrf import CSRFProtect from flask_sqlalchemy import SQLAlchemy -from config import config +from config import app_config csrf = CSRFProtect() app = Flask(__name__) app.config.from_object(__name__) -app.config['SECRET_KEY'] = config['SECRET_KEY'] -app.config['SQLALCHEMY_DATABASE_URI'] = config.get('SQLALCHEMY_DATABASE_URI', 'sqlite:///database.db') +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +app.config.update(app_config) csrf.init_app(app) db = SQLAlchemy(app) diff --git a/smtl/templates/signup_form.html b/smtl/templates/signup_form.html @@ -1,10 +1,10 @@ <form action="/signup" id="signup_form" method="POST"> <table> {% for field in [form.firstname, form.lastname, form.club, form.dwz, form.email] %} - <tr> - <td>{{ field.label }}</td> - <td>{{ field }}</td> - </tr> + <tr> + <td>{{ field.label }}</td> + <td>{{ field }}</td> + </tr> {% endfor %} <tr> <td>