signals.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:django-open-volunteering-platform 作者: OpenVolunteeringPlatform 项目源码 文件源码
def channel_cors(sender, request, **kwargs):
  """
  This signal checks for channel `CORS_ORIGIN_WHITELIST` settings.
  If the channel as a setting where the value match the Origin header
  the request will have the correct Access-Control-Allow-Origin on the response.
  """
  channel = get_channel(request.channel)
  if channel:
    origin = request.META.get("HTTP_ORIGIN", "")
    domain = urlparse(origin).netloc
    if domain in channel["settings"].get("CORS_ORIGIN_WHITELIST", []):
      return True

  return False

# check_request_enabled.connect(channel_cors)

# Custom channel signal
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号