<s> from flask import Flask <EOL> from flask import request <EOL> from flask import jsonify <EOL> import json <EOL> import subprocess <EOL> app = Flask ( __name__ ) <EOL> config = None <EOL> @ app . route ( '<STR_LIT:/>' , methods = [ '<STR_LIT:POST>' ] ) <EOL> def hook_listen ( ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> token = request . args . get ( '<STR_LIT>' ) <EOL> if token == config [ '<STR_LIT>' ] : <EOL> hook = request . args . get ( '<STR_LIT>' ) <EOL> if hook : <EOL> hook_value = config [ '<STR_LIT>' ] . get ( hook ) <EOL> if hook_value : <EOL> try : <EOL> subprocess . call ( hook_value ) <EOL> return jsonify ( success = True ) , <NUM_LIT:200> <EOL> except OSError as e : <EOL> return jsonify ( success = False , error = str ( e ) ) , <NUM_LIT> <EOL> else : <EOL> return jsonify ( success = False , error = "<STR_LIT>" ) , <NUM_LIT> <EOL> else : <EOL> return jsonify ( success = False , error = "<STR_LIT>" ) , <NUM_LIT> <EOL> else : <EOL> return jsonify ( success = False , error = "<STR_LIT>" ) , <NUM_LIT> <EOL> def load_config ( ) : <EOL> with open ( '<STR_LIT>' ) as config_file : <EOL> return json . load ( config_file ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> config = load_config ( ) <EOL> app . run ( host = config . get ( '<STR_LIT:host>' , '<STR_LIT:localhost>' ) , port = config . get ( '<STR_LIT:port>' , <NUM_LIT> ) ) </s>
