code: def append_slash_redirect(environ, code=301):
      
      new_path = environ['PATH_INFO'].strip('/') + '/'
      query_string = environ.get('QUERY_STRING')
      if query_string:
          new_path += '?' + query_string
      return redirect(new_path, code)
docs: Redirect to the same URL but with a slash appended.  The behavior
      of this function is undefined if the path ends with a slash already.
  
      :param environ: the WSGI environment for the request that triggers
                      the redirect.
      :param code: the status code for the redirect.