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
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)

@ -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