コード例 #1
0
ファイル: conftest.py プロジェクト: super-woman/wita_bend
def app():
    """Create application for the tests."""
    _app = create_app("tests.settings")
    ctx = _app.test_request_context()
    ctx.push()
    yield _app

    ctx.pop()
コード例 #2
0
def app():
    db_fd, db_path = tempfile.mkstemp()
    app = create_app({
        'TESTING': True,
        'SQLALCHEMY_DATABASE_URI': 'sqlite:///'+db_path,
    })

    with app.app_context():
        init_db(app)
        
    yield app
    os.close(db_fd)
    os.unlink(db_path)
コード例 #3
0
def create_celery_app(app=None):
    CONFIG = DevConfig if get_debug_flag() else ProdConfig
    app = app or create_app(CONFIG)
    celery = Celery(__name__, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task

    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery
コード例 #4
0
# -*- coding: utf-8 -*-
"""Create an application instance."""
from apps.app import create_app

app = create_app()
コード例 #5
0
# -*- coding: utf-8 -*-
"""Create an application instance."""
from flask.helpers import get_debug_flag

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

CONFIG = DevConfig if get_debug_flag() else ProdConfig

app = create_app(CONFIG)
コード例 #6
0
ファイル: database.py プロジェクト: nlantoing/Astrarium
def db_context(app):
    if app is None:
        app = create_app()
    with app.app_context():
        yield
コード例 #7
0
#!/usr/bin/python
from apps.app import create_app
from flask import abort

app = create_app()

if __name__ == '__main__':
    app.run(debug=True)