old_contents: from flask import Flask
  from celery import Celery
  from werkzeug.debug import DebuggedApplication
  
  from snakeeyes.blueprints.page.views import page
  from snakeeyes.blueprints.contact.views import contact
  from snakeeyes.extensions import debug_toolbar, mail, csrf, flask_static_digest
  
  
  def create_celery_app(app=None):
      """
      Create a new Celery object and tie together the Celery config to the app's
      config. Wrap all tasks in the context of the application.
  
      :param app: Flask app
      :return: Celery app
      """
      app = app or create_app()
  
      celery = Celery(app.import_name)
      celery.conf.update(app.config.get('CELERY_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
  
  
  def create_app(settings_override=None):
      """
      Create a Flask application using the app factory pattern.
  
      :param settings_override: Override settings
      :return: Flask app
      """
      app = Flask(__name__, static_folder='../public', static_url_path='')
  
      app.config.from_object('config.settings')
  
      if settings_override:
          app.config.update(settings_override)
  
      app.register_blueprint(page)
      app.register_blueprint(contact)
      extensions(app)
  
      if app.debug:
          app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
  
      return app
  
  
  def extensions(app):
      """
      Register 0 or more extensions (mutates the app passed in).
  
      :param app: Flask application instance
      :return: None
      """
      debug_toolbar.init_app(app)
      mail.init_app(app)
      csrf.init_app(app)
      flask_static_digest.init_app(app)
  
      return None
  
  
  celery_app = create_celery_app()
  
new_contents: from flask import Flask
  from celery import Celery
  from werkzeug.debug import DebuggedApplication
  
  from snakeeyes.blueprints.page.views import page
  from snakeeyes.blueprints.contact.views import contact
  from snakeeyes.extensions import debug_toolbar, mail, csrf, flask_static_digest
  
  
  def create_celery_app(app=None):
      """
      Create a new Celery object and tie together the Celery config to the app's
      config. Wrap all tasks in the context of the application.
  
      :param app: Flask app
      :return: Celery app
      """
      app = app or create_app()
  
      celery = Celery(app.import_name)
      celery.conf.update(app.config.get('CELERY_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
  
  
  def create_app(settings_override=None):
      """
      Create a Flask application using the app factory pattern.
  
      :param settings_override: Override settings
      :return: Flask app
      """
      app = Flask(__name__, static_folder='../public', static_url_path='')
  
      app.config.from_object('config.settings')
  
      if settings_override:
          app.config.update(settings_override)
  
      app.register_blueprint(page)
      app.register_blueprint(contact)
      extensions(app)
  
      return app
  
  
  def extensions(app):
      """
      Register 0 or more extensions (mutates the app passed in).
  
      :param app: Flask application instance
      :return: None
      """
      debug_toolbar.init_app(app)
      mail.init_app(app)
      csrf.init_app(app)
      flask_static_digest.init_app(app)
  
      return None
  
  
  def middleware(app):
      """
      Register 0 or more middleware (mutates the app passed in).
  
      :param app: Flask application instance
      :return: None
      """
      # Enable the Flask interactive debugger in the brower for development.
      if app.debug:
          app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
  
      return None
  
  
  celery_app = create_celery_app()
  
subject: Move Gunicorn debugger into middleware function