Skip to content

Instantly share code, notes, and snippets.

@wddwycc
Created May 12, 2017 08:14
Show Gist options
  • Select an option

  • Save wddwycc/e561320fd111bc62dedce3175907105e to your computer and use it in GitHub Desktop.

Select an option

Save wddwycc/e561320fd111bc62dedce3175907105e to your computer and use it in GitHub Desktop.
def create_flask_app(config=None):
app = Flask(__name__)
#: load default configuration
app.config.from_object('diadem.settings')
#: load environment configuration
if 'DIADEM_CONF' in os.environ:
app.config.from_envvar('DIADEM_CONF')
#: load app sepcified configuration
if config is not None:
if isinstance(config, dict):
app.config.update(config)
elif config.endswith('.py'):
app.config.from_pyfile(config)
return app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment