예제 #1
0
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
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)