From 9b6798a180c7b2b74a51391af9018c7224e10601 Mon Sep 17 00:00:00 2001 From: Michael Moese Date: Thu, 25 Feb 2021 17:47:41 +0100 Subject: [PATCH 1/2] Add a makefile with some default targets Add some targets - make help, print some usage help. Default target - make setup to install requirements using pip (make sure to activate your virtual environment first) - make test will run the tests - make clean, just a dummy for now Add required tools for testing and code analysis to requirements.txt Signed-off-by: Michael Moese --- Makefile | 23 +++++++++++++++++++++++ requirements.txt | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5a5f5d --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +PYTHON=python3 +PYCODESTYLE=pycodestyle + +.DEFAULT_GOAL = help + +help: + @echo "The following targets are supported:" + @echo " setup install required packages" + @echo " test run the tests" + + +setup: + pip install -r requirements.txt + + +test: + ${PYCODESTYLE} *.py + ${PYTHON} -m pytest + +clean: + @echo "cleaning" + +.PHONY: setup test clean help diff --git a/requirements.txt b/requirements.txt index cbc7c45..706464a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,8 @@ flask flask_flatpages + +pytest +pytest-cov +requests +pycodestyle +codecov From 5884e192f2dc2960b9314ad38695e46ff2f21bb1 Mon Sep 17 00:00:00 2001 From: Michael Moese Date: Thu, 25 Feb 2021 17:52:49 +0100 Subject: [PATCH 2/2] Some pycodestyle cleanups Signed-off-by: Michael Moese --- app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 1a6fe37..256528f 100755 --- a/app.py +++ b/app.py @@ -9,26 +9,31 @@ app.config['FLATPAGES_EXTENSION'] = '.md' pages = FlatPages(app) + @app.route('/.html') def page(path): page = pages.get_or_404(path) return render_template('page.html', page=page) + @app.route('/verein.html') def verein(): return render_template('verein.html') + @app.route('/impressum.html') def impressum(): return render_template('impressum.html') + @app.route('/') @app.route('/index.html') def index(): posts = [p for p in pages if "date" in p.meta] - sorted_pages = sorted(posts, reverse=True, key=lambda page: - datetime.strptime(page.meta["date"], "%d %b %y")) + sorted_pages = sorted(posts, reverse=True, key=lambda page + datetime.strptime(page.meta["date"], "%d %b %y")) return render_template('index.html', pages=sorted_pages) + if __name__ == '__main__': app.run(host='0.0.0.0')