Skip to content
Snippets Groups Projects
Commit 0ea49063 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

docstrings ftw

parent 4eccbb8b
No related branches found
No related tags found
No related merge requests found
Pipeline #
"""Initalize Fractalis Flask app and configure it.
Modules in this package:
- config -- Manages Fractalis Flask app configuration
"""
from flask import Flask
from fractalis.config import configure_app
......
"""This module manages the configuration of the Fractalis flask app.
Exports:
- configure_app -- Function that configures given Flask app
"""
import os
class BaseConfig():
class BaseConfig(object):
"""Basic configuration that should be used in production."""
DEBUG = False
TESTING = False
class DevelopmentConfig(BaseConfig):
"""Configuration used in development."""
DEBUG = True
TESTING = False
class TestingConfig(BaseConfig):
"""Configuration used in testing."""
DEBUG = False
TESTING = True
config = {
'development': 'fractalis.config.DevelopmentConfig',
'testing': 'fractalis.config.TestingConfig',
......@@ -23,6 +32,19 @@ config = {
def configure_app(app):
"""Apply configuration to given flask app based on environment variable.
This function assumes that the environment variable FRACTALIS_MODE contains
the key 'development', 'testing', 'production', or is unset in which case
it defaults to 'production'. Each of these keys maps to a class in this
module that contains appropriate settings.
Arguments:
app (Flask) -- An instance of the app to configure
Exceptions:
KeyError (Exception) -- Is raised when FRACTALIS_MODE contains unknown key
"""
mode = os.getenv('FRACTALIS_MODE', default='production')
try:
app.config.from_object(config[mode])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment