code: def endpoint(request):
      
      s = getServer(request)
  
      query = util.normalDict(request.GET or request.POST)
  
      # First, decode the incoming request into something the OpenID
      # library can use.
      try:
          openid_request = s.decodeRequest(query)
      except ProtocolError, why:
          # This means the incoming request was invalid.
          return direct_to_template(
              request,
              'server/endpoint.html',
              {'error': str(why)})
  
      # If we did not get a request, display text indicating that this
      # is an endpoint.
      if openid_request is None:
          return direct_to_template(
              request,
              'server/endpoint.html',
              {})
  
      # We got a request; if the mode is checkid_*, we will handle it by
      # getting feedback from the user or by checking the session.
      if openid_request.mode in ["checkid_immediate", "checkid_setup"]:
          return handleCheckIDRequest(request, openid_request)
      else:
          # We got some other kind of OpenID request, so we let the
          # server handle this.
          openid_response = s.handleRequest(openid_request)
          return displayResponse(request, openid_response)
docs: Respond to low-level OpenID protocol messages.