
    z-is                     8    d dl mZ d dlmZ d dlZ G d d      Zy)    )settings)HttpResponseNc                       e Zd ZdZd Zd Zy)StaticXFrameOptionsMiddlewareuK   
    为静态 HTML 文件添加 X-Frame-Options 响应头的中间件
    c                     || _         y )N)get_response)selfr   s     $/usr/local/footviz/api/middleware.py__init__z&StaticXFrameOptionsMiddleware.__init__	   s
    (    c                     | j                  |      }|j                  j                  t        j                        r%|j                  j                  d      r
d|d<   d|d<   |S )Nz.html
SAMEORIGINzX-Frame-OptionszSframe-ancestors 'self' http://localhost:* http://127.0.0.1:* https://*.21729901.xyzzContent-Security-Policy)r   path
startswithr   	MEDIA_URLendswith)r	   requestresponses      r
   __call__z&StaticXFrameOptionsMiddleware.__call__   s\    $$W- LL##H$6$67LL!!'**6H&' 3HH./r   N)__name__
__module____qualname____doc__r   r    r   r
   r   r      s    )r   r   )django.confr   django.httpr   osr   r   r   r
   <module>r      s      $ 	 r   