a
    g	g1                     @   s   U d dl mZmZmZmZmZmZ d dlmZ d dl	m
Z
 erfededef dZeegef ed< n,zd dlmZ W n ey   d	d
 ZY n0 eegee
 f Zeeegee
 f Zee edddZdS )    )TYPE_CHECKINGAny	AwaitableCallableIterableTypeVar)Request)StreamResponseF.)bound
middleware)r   c                 C   s   | S )N )xr   r   U/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/blackd/middlewares.py<lambda>       r   )allow_headersreturnc                    s   t tttd fdd}|S )N)requesthandlerr   c                    s   | j dk}|od| jv }|r$t }n|| I d H }| jd}|sF|S d|jd< d|jd< |r~d |jd< dd	|jd
< |S )NOPTIONSzAccess-Control-Request-MethodZOrigin*zAccess-Control-Allow-OriginzAccess-Control-Expose-Headersz, zAccess-Control-Allow-Headers)r   POSTzAccess-Control-Allow-Methods)methodheadersr	   getjoin)r   r   Z
is_optionsZis_preflightresporiginr   r   r   impl   s     



zcors.<locals>.impl)r   r   Handlerr	   )r   r    r   r   r   cors   s    r"   N)typingr   r   r   r   r   r   Zaiohttp.web_requestr   Zaiohttp.web_responser	   r
   __annotations__Zaiohttp.web_middlewaresr   ImportErrorr!   Z
Middlewarestrr"   r   r   r   r   <module>   s   "