Beispiel #1
0
def configure_extensions(app):
    db.app = app
    celery.init_app(app)
    db.init_app(app)
    mail.init_app(app)
    cache.init_app(app)
    celery.init_app(app)
Beispiel #2
0
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)

    db.init_app(app)
    migrate.init_app(app, db)
    login.init_app(app)
    mail.init_app(app)
    bootstrap.init_app(app)
    moment.init_app(app)
    celery.init_app(app)

    from app.errors import bp as errors_bp
    app.register_blueprint(errors_bp)

    from app.auth import bp as auth_bp
    app.register_blueprint(auth_bp, url_prefix='/auth')

    from app.main import bp as main_bp
    app.register_blueprint(main_bp)

    from app.scraping import bp as scraping_bp
    from app.scraping.scraper import Scraper
    from app.scraping import tasks

    app.register_blueprint(scraping_bp, url_prefix='/scraping')
    app.scrapers = {
        "rechem": tasks.rechem_routine_task,
        "test_task": tasks.test_task
    }

    if not app.debug and not app.testing:
        if app.config['LOG_TO_STDOUT']:
            stream_handler = logging.StreamHandler()
            stream_handler.setLevel(logging.INFO)
            app.logger.addHandler(stream_handler)
        else:
            if not os.path.exists('logs'):
                os.mkdir('logs')
            file_handler = RotatingFileHandler('logs/DNMS.log',
                                               maxBytes=10240,
                                               backupCount=10)
            file_handler.setFormatter(
                logging.Formatter('%(asctime)s %(levelname)s: %(message)s '
                                  '[in %(pathname)s:%(lineno)d]'))
            file_handler.setLevel(logging.INFO)
            app.logger.addHandler(file_handler)

            app.logger.setLevel(logging.INFO)
            app.logger.info('DNMS startup')

    return app
Beispiel #3
0
def create_app(object_name):
    app = Flask(__name__)
    app.config.from_object(object_name)

    db.init_app(app)
    mongo.init_app(app)
    bcrypt.init_app(app)
    celery.init_app(app)
    event.listen(Reminder, 'after_insert', on_reminder_save)

    @app.route('/')
    def index():
        return redirect(url_for('blog.home'))

    app.register_blueprint(blog_blueprint)
    app.register_blueprint(main_blueprint)

    return app
Beispiel #4
0
from app import create_app
from extensions import celery
from celery_task_socket import self_test
import eventlet

'''
Enable the monkey_patch if run into a socket issue
'''
#eventlet.monkey_patch()

app = create_app()
celery.init_app(app)
celery.config_from_object('celery_socket_config')
Beispiel #5
0
from extensions import celery

sql_db = None


app = Flask(__name__, static_folder=None)
app.static_url_path = '/static'
bootstrap = Bootstrap(app)
app.static_url_path = None
app.config.from_pyfile('config.cfg')
app.config.from_pyfile('secret.cfg')

# configure/initialize all your extensions

sql_db = celery.init_app(app)

app.wsgi_app = ReverseProxied(app.wsgi_app)

CORS(app)


app.config['BASE_PATH'] = os.getcwd()

if 'STATIC_PATH' not in app.config:
    app.config['STATIC_PATH'] = os.path.join(app.config['BASE_PATH'], 'static')

if 'OUTPUT_PATH' not in app.config:
    app.config['OUTPUT_PATH'] = os.path.join(app.config['STATIC_PATH'], 'output')

if 'UPLOAD_PATH' not in app.config:
Beispiel #6
0
def extensions_load(app):
    db.init_app(app)
    migrate.init_app(app, db)
    celery.init_app(app)
Beispiel #7
0
from app import create_app
from extensions import celery
from celery_task_socket import self_test
import eventlet
'''
Enable the monkey_patch if run into a socket issue
'''
eventlet.monkey_patch()

app = create_app()
celery.init_app(app)
celery.config_from_object('celery_socket_config')
Beispiel #8
0
def register_extensions(app):
    db.init_app(app)
    migrate.init_app(app, db)
    celery.init_app(app)