示例#1
0
 def test_get_debug_flag(self, monkeypatch, debug, expected_flag, expected_default_flag):
     monkeypatch.setenv('FLASK_DEBUG', debug)
     if expected_flag is None:
         assert get_debug_flag() is None
     else:
         assert get_debug_flag() == expected_flag
     assert get_debug_flag(default=True) == expected_default_flag
示例#2
0
    def create_cli_app(info):
        """Application factory for CLI app.

        Internal function for creating the CLI. When invoked via
        ``inveniomanage`` FLASK_APP must be set.
        """
        if create_app is None:
            # Fallback to normal Flask behavior
            info.create_app = None
            app = info.load_app()
        else:
            app = create_app(debug=get_debug_flag())
        return app
示例#3
0
文件: run.py 项目: frascoweb/frasco
def serve_command(info, host, port, reload, debugger, eager_loading,
                with_threads):
    """Runs a local development server for the Flask application.
    This local server is recommended for development purposes only but it
    can also be used for simple intranet deployments.  By default it will
    not support any sort of concurrency at all to simplify debugging.  This
    can be changed with the --with-threads option which will enable basic
    multithreading.
    The reloader and debugger are by default enabled if the debug flag of
    Flask is enabled and disabled otherwise.
    """
    from werkzeug.serving import run_simple

    debug = get_debug_flag()
    if reload is None:
        reload = bool(debug)
    if debugger is None:
        debugger = bool(debug)
    if eager_loading is None:
        eager_loading = not reload

    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)

    # Extra startup messages.  This depends a but on Werkzeug internals to
    # not double execute when the reloader kicks in.
    if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
        # If we have an import path we can print it out now which can help
        # people understand what's being served.  If we do not have an
        # import path because the app was loaded through a callback then
        # we won't print anything.
        if info.app_import_path is not None:
            print(' * Serving Flask app "%s"' % info.app_import_path)
        if debug is not None:
            print(' * Forcing debug mode %s' % (debug and 'on' or 'off'))

    reloader_path = '.'
    if info.app_import_path:
        if os.path.isdir(info.app_import_path):
            reloader_path = info.app_import_path
        elif os.path.isfile(info.app_import_path):
            reloader_path = os.path.dirname(info.app_import_path)
    extra_files = get_reloader_extra_files(reloader_path)

    run_simple(host, port, app, use_reloader=reload, extra_files=extra_files,
               use_debugger=debugger, threaded=with_threads)
示例#4
0
文件: autoapp.py 项目: loleg/dribdat
# -*- coding: utf-8 -*-
"""Create an application instance."""
from flask.helpers import get_debug_flag

from dribdat.app import create_app
from dribdat.settings import DevConfig, ProdConfig

CONFIG = DevConfig if get_debug_flag() else ProdConfig

app = create_app(CONFIG)
示例#5
0
 def test_get_env(self, monkeypatch, env, ref_env, debug):
     monkeypatch.setenv("FLASK_ENV", env)
     assert get_debug_flag() == debug
     assert get_env() == ref_env
示例#6
0
from flask.helpers import get_debug_flag
from donate.app import create_app
from donate.settings import DevConfig, ProdConfig

CONFIG = DevConfig if get_debug_flag() else ProdConfig

app = create_app(CONFIG)
示例#7
0
 def test_get_env(self, monkeypatch, env, ref_env, debug):
     monkeypatch.setenv("FLASK_ENV", env)
     assert get_debug_flag() == debug
     assert get_env() == ref_env
示例#8
0
from flask.helpers import get_debug_flag
from gazo import api, settings

CONFIG = settings.DevConfig if get_debug_flag() else settings.ProdConfig
app = api.create_app(CONFIG)
app.config["JSON_SORT_KEYS"] = False
app.run(host=app.config['HOST_BASENAME'], port=app.config['HOST_PORT'])
示例#9
0
def get_current_config():
    return DevConfig if get_debug_flag() else ProdConfig
示例#10
0
from gevent import monkey
monkey.patch_all()

import psycogreen.gevent
psycogreen.gevent.patch_psycopg()

from flask.helpers import get_debug_flag

from app.app import create_app
from app.extensions import socketio
from app.settings import DevConfig, ProdConfig

CONFIG = DevConfig if get_debug_flag() else ProdConfig

app = create_app(CONFIG)

if __name__ == '__main__' and get_debug_flag():
    socketio.run(app)
示例#11
0
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()

from flask.helpers import get_debug_flag
from app.settings import AppConfig
from app.app import create_app

app = create_app(AppConfig)

if __name__ == "__main__" and get_debug_flag():
    app.run()
示例#12
0
def create_hxprezi(info):
    config = DevConfig if get_debug_flag() else ProdConfig
    return create_app(config)
示例#13
0
# -*- coding: utf-8 -*-
"""Create an application instance."""
import importlib
import os

from flask.helpers import get_debug_flag

from pyxword_contest.app import create_app


def import_string(name):
    module_name, attr_name = name.rsplit('.', 1)
    mod = importlib.import_module(module_name)
    return getattr(mod, attr_name)


config_factory_name = os.environ.get('PYXWORD_SETTINGS')
if not config_factory_name:
    config_factory_name = ('DevConfig' if get_debug_flag() else 'ProdConfig')

if '.' not in config_factory_name:
    config_factory_name = f'pyxword_contest.settings.{config_factory_name}'

config_factory = import_string(config_factory_name)

CONFIG = config_factory()

app = create_app(CONFIG)