Ejemplo n.º 1
0
def app_tool(info):
    app = create_app(os.environ['HIVE_APP'])
    return app
Ejemplo n.º 2
0
def app_tool(info):
    from flask_sqlalchemy import SQLAlchemy
    app = create_app(os.environ['HIVE_APP'], db=SQLAlchemy())
    return app
Ejemplo n.º 3
0
sys.path.insert(
    0, os.path.join(os.path.abspath(__file__).rsplit('/', 2)[0], 'project-a'))
sys.path.insert(0, os.path.dirname(__file__))

# 关闭一些高级特性
os.environ['FANTASY_ACTIVE_CACHE'] = 'no'
os.environ['FANTASY_ACTIVE_SENTRY'] = 'no'
# hardcode end

from fantasy import create_app
from werkzeug.wsgi import DispatcherMiddleware

os.environ.setdefault('FANTASY_SETTINGS_MODULE', 'web.conf')
os.environ.setdefault('FANTASY_PRIMARY_NODE', 'yes')

app = DispatcherMiddleware(create_app('hello'))

if __name__ == '__main__':
    import os
    from werkzeug.serving import run_simple

    bind_ip = os.environ.get('FLASK_SIMPLE_BIND', '127.0.0.1')

    run_simple(bind_ip,
               5001,
               app,
               use_reloader=True,
               use_debugger=True,
               use_evalex=True)
Ejemplo n.º 4
0
sys.path.insert(0, os.path.dirname(__file__))

# 关闭一些高级特性
os.environ['FANTASY_ACTIVE_DB'] = 'no'
os.environ['FANTASY_ACTIVE_CACHE'] = 'no'
os.environ['FANTASY_ACTIVE_SENTRY'] = 'no'
os.environ['FANTASY_ACTIVE_ACCOUNT'] = 'no'
# hardcode end

from fantasy import create_app
from werkzeug.wsgi import DispatcherMiddleware

os.environ.setdefault('FANTASY_SETTINGS_MODULE', 'web.conf')

app = DispatcherMiddleware(
    create_app('welcome'), {
        '/hello': create_app('hello'),
        '/teamwork/app3': create_app('teamwork.app3'),
        '/teamwork/app2/01': create_app('teamwork.app2.app1'),
        '/teamwork/app2': create_app('teamwork.app2'),
        '/teamwork/app1': create_app('teamwork.app1'),
        '/teamwork': create_app('teamwork'),
    })

if __name__ == '__main__':
    import os
    from werkzeug.serving import run_simple

    bind_ip = os.environ.get('FLASK_SIMPLE_BIND', '127.0.0.1')

    run_simple(bind_ip,
Ejemplo n.º 5
0
def app(request):
    if not pytest.entry_app:
        raise KeyError("Please set `entry_app` namespace.")

    app_config = {
        key: getattr(pytest.app_config, key)
        for key in dir(pytest.app_config) if not key.startswith('_')
    }

    if hasattr(pytest, 'entry_config'):
        temp_config = {
            key: getattr(pytest.entry_config, key)
            for key in dir(pytest.entry_config) if not key.startswith('_')
        }

        entry_config = {}
        for key, value in temp_config.items():
            if hasattr(value,
                       '__name__') and \
                    value.__name__.split('.', 1)[0] == 'pytest':
                entry_config[key] = {
                    k: getattr(value, k)
                    for k in dir(value) if not k.startswith('_')
                }
            else:
                entry_config[key] = value
            pass

        app_config.update(entry_config)

    from fantasy import create_app

    db = None
    if pytest.active_db:
        from flask_sqlalchemy import SQLAlchemy
        db = SQLAlchemy()
        pass

    celery = None
    if pytest.active_celery:
        from celery import Celery
        celery = Celery(pytest.entry_app)
        pass

    app = create_app(pytest.entry_app, app_config, db, celery)

    yield app

    if pytest.active_db:
        from sqlalchemy.engine.url import make_url
        from sqlalchemy_utils import drop_database
        drop_database(make_url(app_config['SQLALCHEMY_DATABASE_URI']))

    mongodb_config = app.config.get('MONGODB_SETTINGS')

    if mongodb_config:
        try:
            from mongoengine.connection import get_db
            current_mongodb = get_db()
            current_mongodb.client.drop_database(mongodb_config['DB'])
        except Exception as e:
            print("drop mongodb ignored", e)
            pass

    if hasattr(pytest, 'entry_tear_down'):
        func = getattr(pytest, 'entry_tear_down')
        func(app)
        pass

    pass
Ejemplo n.º 6
0
sys.path.insert(0, os.path.dirname(__file__))

os.environ['FANTASY_PRIMARY_NODE'] = 'yes'
# 关闭一些高级特性
os.environ['FANTASY_ACTIVE_CACHE'] = 'no'
os.environ['FANTASY_ACTIVE_SENTRY'] = 'no'
# hardcode end

from fantasy import create_app
from werkzeug.wsgi import DispatcherMiddleware

db = SQLAlchemy()

os.environ.setdefault('FANTASY_SETTINGS_MODULE', 'web.conf')

app = DispatcherMiddleware(create_app('welcome', db=db))

if __name__ == '__main__':
    import os
    from werkzeug.serving import run_simple

    bind_ip = os.environ.get('FLASK_SIMPLE_BIND', '127.0.0.1')

    run_simple(bind_ip,
               5000,
               app,
               use_reloader=True,
               use_debugger=True,
               use_evalex=True)
Ejemplo n.º 7
0
# manage.py
import os
import logging

from flask import url_for

from fantasy import create_app
from fantasy.config import ProductionConfig, DevelopmentConfig

from flask_script import Manager, Shell


if os.environ.get('PRODUCTION'):
    app = create_app(config = ProductionConfig)
else:
    app = create_app()

manager = Manager(app)


@manager.command
def routes():
    """ Prints out all the routes to shell
    """
    import urllib.request, urllib.parse, urllib.error
    output = []
    for rule in app.url_map.iter_rules():
        options = {}
        for arg in rule.arguments:
            options[arg] = "[{0}]".format(arg)
        methods = ','.join(rule.methods)
Ejemplo n.º 8
0
"""
import os
import sys

sys.path.insert(0, __file__.rsplit('/', 2)[0])

from fantasy import create_app  # noqa: E402
from werkzeug.wsgi import DispatcherMiddleware  # noqa: E402
from flask_sqlalchemy import SQLAlchemy  # noqa: E402

os.environ.setdefault('HIVE_APP', 'welcome')  # 此行仅为了演示方便
os.environ.setdefault('FANTASY_SETTINGS_MODULE', 'web.conf')  # 此行仅为了演示方便

db = SQLAlchemy()

app = DispatcherMiddleware(create_app('accounts.username', db=db))

if __name__ == '__main__':
    import os
    from werkzeug.serving import run_simple

    bind_ip = os.environ.get('FLASK_SIMPLE_BIND', '0.0.0.0')

    run_simple(bind_ip,
               5000,
               app,
               use_reloader=False,
               use_debugger=False,
               use_evalex=True)