Example #1
0
def create_celery(app=None):
    """Celery instantiation."""
    app = create_app()
    celery = Celery(app,
                    backend=app.config['CELERY_RESULT_BACKEND'],
                    broker=app.config['CELERY_BROKER_URL'])
    print(app.config['CELERY_RESULT_BACKEND'])
    app.config['CELERYBEAT_SCHEDULE'] = {
        # Executes every minute
        'periodic_task-every-minute': {
            'task': 'delete_expired_urls',
            'schedule': crontab(minute="*")
        }
    }
    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
Example #2
0
from app_creator import create_app

app = create_app()

if __name__ == '__main__':
    app.run(debug=True)
 def setUp(self):
     self.app = create_app('test')
     self.api = create_api(self.app)
     self.test_client = self.app.test_client()
     self.db = db
Example #4
0
from werkzeug.contrib.fixers import ProxyFix

from app_creator import create_app

app = create_app('etc.settings')[0]
app.wsgi_app = ProxyFix(app.wsgi_app)
Example #5
0
def app():
    app = create_app()
    api = Api(app)
    api.add_resource(UrlAPI, '/api/v1/url', 'urls')
    return app
Example #6
0
def main():
    '''runs the flask app
    '''
    app = create_app('etc.settings')[0]
    
    run_simple('0.0.0.0', 5000, app, True, True)