<s> from werkzeug . routing import Map , Rule <EOL> from werkzeug . wrappers import Response <EOL> from kaylee import kl <EOL> def kaylee_register_node ( request ) : <EOL> reg_data = kl . register ( request . remote_addr ) <EOL> return json_response ( reg_data ) <EOL> def kaylee_subscribe_node ( request , app_name , node_id ) : <EOL> node_config = kl . subscribe ( node_id , app_name ) <EOL> return json_response ( node_config ) <EOL> def kaylee_process_task ( request , node_id ) : <EOL> if request . method == '<STR_LIT:GET>' : <EOL> return json_response ( kl . get_action ( node_id ) ) <EOL> else : <EOL> data = request . data . decode ( '<STR_LIT:utf-8>' ) <EOL> next_task = kl . accept_result ( node_id , data ) <EOL> return json_response ( next_task ) <EOL> def json_response ( s ) : <EOL> return Response ( s , mimetype = '<STR_LIT:application/json>' ) <EOL> def make_url_map ( url_prefix = '<STR_LIT>' ) : <EOL> return Map ( [ <EOL> Rule ( url_prefix + '<STR_LIT>' , <EOL> methods = [ '<STR_LIT:GET>' ] , <EOL> endpoint = kaylee_register_node ) , <EOL> Rule ( url_prefix + '<STR_LIT>' , <EOL> methods = [ '<STR_LIT:POST>' ] , <EOL> endpoint = kaylee_subscribe_node ) , <EOL> Rule ( url_prefix + '<STR_LIT>' , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = kaylee_process_task ) <EOL> ] ) </s>
