Example #1
0
def register_blueprint_4_flask_app(flask_app: flask.app.Flask,
                                   blueprint: flask.Blueprint, silent: bool,
                                   *args):
    try:
        flask_app.register_blueprint(blueprint)
    except AttributeError as e:
        error_info = ('Found disabled/broken Blueprint', *args)
        if silent:
            print(error_info)
        else:
            raise AttributeError(error_info)
Example #2
0
def activate_bot_msg_handling(app: flask.app.Flask) -> None:
    """Register a route to handle bot messages."""
    def bot_message_with_error_catching():
        try:
            return bot_message()
        except Exception:
            logger.exception(
                "Unexpected error occurred handling a bot message")
            _send_myself_error_msg("<uncaught> occurred")
            raise

    app.add_url_rule("/bot/message",
                     "bot_message",
                     bot_message_with_error_catching,
                     methods=["POST"])
Example #3
0
def init_app(app: flask.app.Flask) -> None:
    """Initialize the app."""
    app.before_request(load)
Example #4
0
def init_app(app: flask.app.Flask, redis: Redis) -> None:
    """Initialize the app."""
    app.before_request(partial(before, redis))
Example #5
0
def init_app(app: flask.app.Flask) -> None:
    """Initialize the app."""
    app.before_request(_before)
    app.after_request(_after)
Example #6
0
 def set_up_database(app: flask.app.Flask):
     with app.app_context():
         Seeder.reset_database()
         Seeder.seed_database()
Example #7
0
def init_app(app: flask.app.Flask,
             pool: psycopg2.pool.ThreadedConnectionPool) -> None:
    """Initialize the app."""
    app.before_request(partial(connect, pool))
    app.teardown_appcontext(close)