datasette-cors/datasette_cors.py
from asgi_cors import asgi_corsfrom datasette import hookimpl@hookimpldef asgi_wrapper(datasette):config = datasette.plugin_config("datasette-cors") or {}allow_all = config.get("allow_all") or Falsehosts = config.get("hosts") or []host_wildcards = config.get("host_wildcards") or []def wrap_with_asgi_cors(app):if not (hosts or host_wildcards or allow_all):return appreturn asgi_cors(app,allow_all=allow_all,hosts=hosts,host_wildcards=host_wildcards,)return wrap_with_asgi_cors