<commit_before># -*- coding: utf-8 -*-
"""The app module, containing the app factory function."""
from flask import Flask, render_template

from store import commands, public, user, book
from store.assets import assets
from store.extensions import bcrypt, cache, csrf_protect, db, debug_toolbar, login_manager, migrate
from store.settings import ProdConfig


def create_app(config_object=ProdConfig):
    """An application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/.

    :param config_object: The configuration object to use.
    """
    app = Flask(__name__.split('.')[0])
    app.config.from_object(config_object)
    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    register_shellcontext(app)
    register_commands(app)
    return app


def register_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None


def register_blueprints(app):
    """Register Flask blueprints."""
    app.register_blueprint(public.views.blueprint)
    app.register_blueprint(user.views.blueprint)
     # add a URL prefix "/cellar" implies your routes will be prepended with /cellar
    # E.g. book, order
    # This way you "/" route in cellar will actually load otherwise you public's
    # "/" route will override cellar's "/" route.
    # Perhaps order of blueprints determines this behaviour.
    app.register_blueprint(book.views.book_blueprint)
    return None


def register_errorhandlers(app):
    """Register error handlers."""
    def render_error(error):
        """Render error template."""
        # If a HTTPException, pull the `code` attribute; default to 500
        error_code = getattr(error, 'code', 500)
        return render_template('{0}.html'.format(error_code)), error_code
    for errcode in [401, 404, 500]:
        app.errorhandler(errcode)(render_error)
    return None


def register_shellcontext(app):
    """Register shell context objects."""
    def shell_context():
        """Shell context objects."""
        return {
            'db': db,
            'User': user.models.User,
            'book': book.models.Book
            }

    app.shell_context_processor(shell_context)


def register_commands(app):
    """Register Click commands."""<commit_msg>added orders into app.py<commit_after># -*- coding: utf-8 -*-
"""The app module, containing the app factory function."""
from flask import Flask, render_template

from store import commands, public, user, book, orders
from store.assets import assets
from store.extensions import bcrypt, cache, csrf_protect, db, debug_toolbar, login_manager, migrate
from store.settings import ProdConfig


def create_app(config_object=ProdConfig):
    """An application factory, as explained here: http://flask.pocoo.org/docs/patterns/appfactories/.

    :param config_object: The configuration object to use.
    """
    app = Flask(__name__.split('.')[0])
    app.config.from_object(config_object)
    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    register_shellcontext(app)
    register_commands(app)
    return app


def register_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None


def register_blueprints(app):
    """Register Flask blueprints."""
    app.register_blueprint(public.views.blueprint)
    app.register_blueprint(user.views.blueprint)
     # add a URL prefix "/cellar" implies your routes will be prepended with /cellar
    # E.g. book, order
    # This way you "/" route in cellar will actually load otherwise you public's
    # "/" route will override cellar's "/" route.
    # Perhaps order of blueprints determines this behaviour.
    app.register_blueprint(book.views.book_blueprint)
    return None


def register_errorhandlers(app):
    """Register error handlers."""
    def render_error(error):
        """Render error template."""
        # If a HTTPException, pull the `code` attribute; default to 500
        error_code = getattr(error, 'code', 500)
        return render_template('{0}.html'.format(error_code)), error_code
    for errcode in [401, 404, 500]:
        app.errorhandler(errcode)(render_error)
    return None


def register_shellcontext(app):
    """Register shell context objects."""
    def shell_context():
        """Shell context objects."""
        return {
            'db': db,
            'User': user.models.User,
            'book': book.models.Book,
            'Order': orders.models.Order
            }

    app.shell_context_processor(shell_context)


def register_commands(app):
    """Register Click commands."""
{'fraction_non_alphanumeric': 0.10949631694206649, 'fraction_numerical': 0.007167031654389807, 'mean_word_length': 3.493738819320215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5150314', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1444, 'n_words': 391}