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)

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 )
redirect to the same url but with a slash appended .