code: def asgi_static(
      root_path, chunk_size=4096, headers=None, content_type=None
  ):
      root_path = Path(root_path)
  
      async def inner_static(request, send):
          path = request.scope["url_route"]["kwargs"]["path"]
          try:
              full_path = (root_path / path).resolve().absolute()
          except FileNotFoundError:
              await asgi_send_html(
                  send, "404: Directory not found", 404
              )
              return
          if full_path.is_dir():
              await asgi_send_html(
                  send, "403: Directory listing is not allowed", 403
              )
              return
          # Ensure full_path is within root_path to avoid weird "../" tricks
          try:
              full_path.relative_to(root_path.resolve())
          except ValueError:
              await asgi_send_html(
                  send, "404: Path not inside root path", 404
              )
              return
          try:
              await asgi_send_file(
                  send, full_path, chunk_size=chunk_size
              )
          except FileNotFoundError:
              await asgi_send_html(send, "404: File not found", 404)
              return
  
      return inner_static
  
imports: import json
  from datasette.utils import MultiParams
  from mimetypes import guess_type
  from urllib.parse import parse_qs, urlunparse, parse_qsl
  from pathlib import Path
  from http.cookies import SimpleCookie, Morsel
  import aiofiles
  import aiofiles.os
label_desc: Use image node_id 1 for calling a global function with example usage: asgi_static(root_path, chunk_size, headers, content_type) and returns: inner_static