Move app configuration into config.py

Create a configurstion in a seperate config file that is loaded at
startup, allowing for proper configuration.

Signed-off-by: Michael Moese <mmoese@suse.com>
pull/53/head
Michael Moese 2 years ago
parent bd4e5bec07
commit fd8f75a1b1

@ -8,20 +8,17 @@ from flask_fontawesome import FontAwesome
from datetime import datetime from datetime import datetime
import locale import locale
from config import Config
from fotogrid import fotogrid from fotogrid import fotogrid
from feed import generate_feed from feed import generate_feed
from utils import markdown_with_jinja_renderer, format_date_string, sort_date_from_string, is_future_date from utils import markdown_with_jinja_renderer, format_date_string, sort_date_from_string, is_future_date
# create app # create app
app = Flask(__name__) 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' # load configuration from config file
app.config['FLATPAGES_EVENTS_HTML_RENDERER'] = markdown_with_jinja_renderer config = Config
app.config['FLATPAGES_EVENTS_ROOT'] = 'events' app.config.from_object(config)
app.config['FONTAWESOME_STYLES'] = ['solid', 'brands']
# register fotogrid with jinja # register fotogrid with jinja
app.jinja_env.globals.update(fotogrid=fotogrid) app.jinja_env.globals.update(fotogrid=fotogrid)
@ -81,5 +78,5 @@ def rss():
if __name__ == '__main__': if __name__ == '__main__':
locale.setlocale(locale.LC_TIME, "de_DE") locale.setlocale(locale.LC_TIME, config.LOCALE)
app.run(host='0.0.0.0') app.run(host=config.HOST, port=config.PORT)

@ -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'
Loading…
Cancel
Save