def do_GET()

in google/resource-snippets/compute-v1/healthz_server.py [0:0]


  def do_GET(self):  # pylint: disable=C0103
    """Handler for GET requests."""
    parsed_path = urlparse.urlparse(self.path)
    response_code = 400
    if parsed_path.path == '/change_status':
      HealthzHandler.health_status = parsed_path.query
      print 'changed health status to ' + HealthzHandler.health_status
      response_code = 200
    elif parsed_path.path == '/healthz':
      if HealthzHandler.health_status == 'HEALTHY':
        response_code = 200
      elif HealthzHandler.health_status == 'UNHEALTHY':
        response_code = 500
    self.send_response(response_code)
    self.send_header('Content-type', 'text/html')
    self.end_headers()
    self.wfile.write(HealthzHandler.health_status)