code: def serve_static(app, base_url, base_path, index=False):
      
      @app.route(base_url + '/(.*)')
      def serve(env, req):
          """
          Static files
          """
          try:
              base = pathlib.Path(base_path).resolve()
              path = (base / req.match.group(1)).resolve()
          except FileNotFoundError:
              return Response(None, 404, 'Not Found')
  
  
          # Don't let bad paths through
          if base == path or base in path.parents:
              if path.is_file():
                  return ResponseFile(str(path))
              if index and path.is_dir():
                  if base == path:
                      ret = ''
                  else:
                      ret = '<a href="../">../</a><br/>\r\n'
                  for item in path.iterdir():
                      name = item.parts[-1]
                      if item.is_dir():
                          name += '/'
                      ret += '<a href="{}">{}</a><br/>\r\n'.format(urllib.parse.quote(name), html.escape(name))
                  ret = ResponseString(ret, 'text/html')
                  return ret
  
          return Response(None, 404, 'Not Found')
docs: Serve a directory statically
  
      Parameters:
  
          * app: Grole application object
          * base_url: Base URL to serve from, e.g. /static
          * base_path: Base path to look for files in
          * index: Provide simple directory indexes if True