a c@sddlZddlmZddlmZddlmZddlmZddl m Z m Z m Z z$ddl Z ee drhe jZne jZWneydZ Yn0Gdd d eZGd d d ZdS) N)PathLike)BackgroundTask)Request)Response)ReceiveScopeSend pass_contextcsheZdZdZd ejeeejej e e feje eje dfdd Z e eeddfdd ZZS) _TemplateResponsez text/htmlN)templatecontext status_codeheaders media_type backgroundcs.||_||_||}t|||||dSN)r r rendersuper__init__)selfr r rrrrcontent __class__a/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/starlette/templating.pyrs  z_TemplateResponse.__init__)scopereceivesendreturncsZ|jdi}|di}d|vr@|d|j|jddIdHt|||IdHdS)Nrequest extensionszhttp.response.debug)r r )typeinfo)r getr r__call__)rrrrr r!rrrr%)s  z_TemplateResponse.__call__)r NNN)__name__ __module__ __qualname__rtypingAnydictintOptionalMappingstrrrrrrr% __classcell__rrrrr sr c @seZdZdZdejeefejej ej e gej eej ffej ddddZejeefej dddd Zed d d d ZdeeeejejeefejeejeedddZdS)Jinja2Templatesz} templates = Jinja2Templates("templates") return templates.TemplateResponse("index.html", {"request": request}) N) directorycontext_processors env_optionsrcKs2tdusJd|j|fi||_|p*g|_dS)Nz/jinja2 must be installed to use Jinja2Templates)jinja2 _create_envenvr3)rr2r3r4rrrr@szJinja2Templates.__init__zjinja2.Environment)r2r4rcKsZttttjtddd}t|}|d||ddtjfi|}||j d<|S)N)r name path_paramsrc[s|d}|j|fi|S)Nr )url_for)r r8r9r rrrr:Osz,Jinja2Templates._create_env..url_forloaderZ autoescapeTr:) r r+r/r)r*r5ZFileSystemLoader setdefault Environmentglobals)rr2r4r:r;r7rrrr6Ls    zJinja2Templates._create_envzjinja2.Template)r8rcCs |j|Sr)r7 get_template)rr8rrrr?\szJinja2Templates.get_templater )r8r rrrrrc CsXd|vrtdtt|d}|jD]}|||q&||} t| |||||dS)Nr z$context must include a "request" key)rrrr) ValueErrorr)castrr3updater?r ) rr8r rrrrr Zcontext_processorr rrrTemplateResponse_s   z Jinja2Templates.TemplateResponse)N)r NNN)r&r'r(__doc__r)Unionr/rr-ListCallablerDictr*rr6r?r+r,r.rr rCrrrrr19s6     r1)r)osrZstarlette.backgroundrZstarlette.requestsrZstarlette.responsesrZstarlette.typesrrrr5hasattrr Zcontextfunction ImportErrorr r1rrrrs        !