def add_handler(app, handler_name, func, key=None):
 handler_adder = getattr(app, handler_name)
 handler_funcs_name = '{0}_funcs'.format(handler_name)
 handler_funcs = getattr(app, handler_funcs_name)
 if (func not in handler_funcs.get(key, [])):
  handler_adder(func)

def add_handler ( app , handler_name , func , key = None ) : handler_adder = getattr ( app , handler_name ) handler_funcs_name = '{0}_funcs' . format ( handler_name ) handler_funcs = getattr ( app , handler_funcs_name ) if ( func not in handler_funcs . get ( key , [ ] ) ) : handler_adder ( func )
add handler to flask application if handler has not already been added .