Exemple #1
0
def app(versionfile, docker_env_vars, api_url):
    app = create_app(version_path=versionfile.strpath,
                     secret_key=str(binascii.b2a_hex(os.urandom(15))),
                     session_cookie_name='lando-ui',
                     session_cookie_domain='lando-ui.test:7777',
                     session_cookie_secure=False,
                     use_https=0,
                     enable_asset_pipeline=False,
                     lando_api_url=api_url,
                     debug=True)

    # Turn on the TESTING setting so that exceptions within the app bubble up
    # to the test runner.  Otherwise Flask will hide the exception behind a
    # generic HTTP 500 response, and that makes writing and debugging tests
    # much harder.
    app.config['TESTING'] = True

    return app
Exemple #2
0
def create_dev_app(**kwargs):
    """Create the development server for Flask."""
    params = {
        "debug": False,
        "version_path": "/app/version.json",
        "secret_key": None,
        "session_cookie_name": None,
        "session_cookie_domain": None,
        "session_cookie_secure": True,
        "use_https": True,
        "enable_asset_pipeline": True,
        "lando_api_url": None,
    }

    # These are parameters that should be converted to a boolean value.
    bool_param_keys = (
        "debug",
        "session_cookie_secure",
        "use_https",
        "enable_asset_pipeline",
    )

    for key in params:
        # Replace configuration defaults with environment variables.
        if key.upper() in os.environ:
            params[key] = os.environ[key.upper()]

    # Replace configuration parameters with keyword arguments.
    params.update(kwargs)

    # Guess boolean value based on string input.
    for bool_param in bool_param_keys:
        if bool_param in params and not isinstance(params[bool_param], bool):
            params[bool_param] = str2bool(params[bool_param])

    app = create_app(**params)
    app.jinja_env.auto_reload = True
    app.config["TEMPLATES_AUTO_RELOAD"] = True
    return app
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
In order to build assets, the `flask assets build` command requires a
reference to a python file which has an `app` variable available to import.
This file provides that by initializing the flask app with basic configuration.
If you just want to build assets run `invoke build_assets`, the output can
be found in the landoui/static/build folder.
"""
import binascii
import os

from landoui.app import create_app

app = create_app(version_path='/version.json',
                 secret_key=str(binascii.b2a_hex(os.urandom(15))),
                 session_cookie_name='lando-ui.test',
                 session_cookie_domain='lando-ui.test',
                 session_cookie_secure=False,
                 use_https=0,
                 enable_asset_pipeline=True,
                 lando_api_url='http://lando-api.test',
                 debug=True)