def switch_host_with_param(request, param_name):
 request_json = json.loads(request.data.decode('utf-8'))
 if request_json.get(param_name):
  new_endpoint = request_json[param_name]
  _switch_hosts(request, new_endpoint)

def switch_host_with_param ( request , param_name ) : request_json = json . loads ( request . data . decode ( 'utf-8' ) ) if request_json . get ( param_name ) : new_endpoint = request_json [ param_name ] _switch_hosts ( request , new_endpoint )
switches the host using a parameter value from a json request body .