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)
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"])
def init_app(app: flask.app.Flask) -> None: """Initialize the app.""" app.before_request(load)
def init_app(app: flask.app.Flask, redis: Redis) -> None: """Initialize the app.""" app.before_request(partial(before, redis))
def init_app(app: flask.app.Flask) -> None: """Initialize the app.""" app.before_request(_before) app.after_request(_after)
def set_up_database(app: flask.app.Flask): with app.app_context(): Seeder.reset_database() Seeder.seed_database()
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)