diff --git a/app.py b/app.py index 733d5ef..107fb1d 100755 --- a/app.py +++ b/app.py @@ -8,20 +8,17 @@ from flask_fontawesome import FontAwesome from datetime import datetime import locale +from config import Config from fotogrid import fotogrid from feed import generate_feed from utils import markdown_with_jinja_renderer, format_date_string, sort_date_from_string, is_future_date # create app app = Flask(__name__) -app.config['FLATPAGES_PAGES_EXTENSION'] = '.md' -app.config['FLATPAGES_PAGES_HTML_RENDERER'] = markdown_with_jinja_renderer -app.config['FLATPAGES_EVENTS_EXTENSION'] = '.md' -app.config['FLATPAGES_EVENTS_HTML_RENDERER'] = markdown_with_jinja_renderer -app.config['FLATPAGES_EVENTS_ROOT'] = 'events' - -app.config['FONTAWESOME_STYLES'] = ['solid', 'brands'] +# load configuration from config file +config = Config +app.config.from_object(config) # register fotogrid with jinja app.jinja_env.globals.update(fotogrid=fotogrid) @@ -81,5 +78,5 @@ def rss(): if __name__ == '__main__': - locale.setlocale(locale.LC_TIME, "de_DE") - app.run(host='0.0.0.0') + locale.setlocale(locale.LC_TIME, config.LOCALE) + app.run(host=config.HOST, port=config.PORT) diff --git a/config.py b/config.py new file mode 100644 index 0000000..29a05d2 --- /dev/null +++ b/config.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-3.0 +# vim: set sw=4 ts=4 ex +from utils import markdown_with_jinja_renderer + +class Config: + """ configuration for application """ + FLATPAGES_PAGES_EXTENSION = '.md' + FLATPAGES_PAGES_HTML_RENDERER = markdown_with_jinja_renderer + FLATPAGES_EVENTS_EXTENSION = '.md' + FLATPAGES_EVENTS_HTML_RENDERER = markdown_with_jinja_renderer + FLATPAGES_EVENTS_ROOT = 'events' + FONTAWESOME_STYLES = ['solid', 'brands'] + HOST = '0.0.0.0' + PORT = 9123 + LOCALE = 'de_DE'