L iG&UddlmZddlZddlZddlmZmZmZmZddl Z ddl m Z m Z ddlmZmZmZer ddlmZmZmZej,dZdZd ed <dd Zdd ZGd de j8j:ZGdde j8j<ZGdde j8j<Z Gdde j8j<Z!Gdde!Z"gdZ#Gdde!Z$y)) annotationsN) TYPE_CHECKINGAnyFinalcast)config file_util)allowlisted_origins emit_endpoint_deprecation_noticeis_xsrf_enabled) AwaitableCallableSequencez(?:\.html$|^manifest\.json$)i3r"STATIC_ASSET_CACHE_MAX_AGE_SECONDSc\tjd xstjdS)a0True if cross-origin requests from any origin are allowed. We only allow ALL cross-origin requests when CORS protection has been disabled with server.enableCORS=False or if using the Node server in dev mode. When in dev mode, we have a dev and prod port, which count as two origins. zserver.enableCORSglobal.developmentMode)r get_optiona/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/web/server/routes.pyallow_all_cross_origin_requestsr)s0  !45 5 9J9J :rc<t|tsy|tvS)NF) isinstancestrr )origins ris_allowed_originr7s fc " (* **rcTeZdZ d dfd ZddZdfd Zd fd ZxZS) StaticFileHandlerc4||_t| ||yN)_reserved_pathssuper initialize)selfpathdefault_filenamereserved_paths __class__s rr#zStaticFileHandler.initialize>s . 4!12rct|dk(}|stj|r|jddy|jddty)zDisable cache for HTML files and manifest.json. Other assets like JS and CSS are suffixed with their hash, so they can be cached indefinitely. r Cache-Controlno-cachezpublic, immutable, max-age=N)lenNO_CACHE_PATTERNsearch set_headerr)r$r% is_index_urls rset_extra_headersz#StaticFileHandler.set_extra_headersHsM4yA~ +2248 OOOZ 8 OO-.P-QR rc4 t|||S#tjj$r}|j dk(r|j tj jdk7r*jtj jdtfd|jDr|j|jxsd|_|j|j|j }t|||cYd}~Sd}~wwxYw)N/c3@K|]}j|ywr )endswith).0xurl_paths r z;StaticFileHandler.validate_absolute_path..esJx((+Js index.html)r"validate_absolute_pathtornadoweb HTTPError status_coder%ossepreplaceanyr!parse_url_pathr&get_absolute_pathroot)r$rG absolute_pather9r(s @rr<z(StaticFileHandler.validate_absolute_pathYs 71$ F F{{$$ }}#9977;;#%'// SAHJT5I5IJJ //0E0E0UV $ 6 6tyy$)) L w5dMJJ ! s!DCD DDDc |dk(rDtjjtjd}|j |yt ||fi|y)Nr3r;)rAr%joinr get_static_dirrenderr" write_error)r$r@kwargs index_filer(s rrNzStaticFileHandler.write_errornsF # i&>&>&@,OJ KK # G  6v 6r)Nr)r%rr& str | Noner'z Sequence[str]returnNone)r%rrRrS)rGrrHrrRrQ)r@intrOrrRrS)__name__ __module__ __qualname__r#r1r<rN __classcell__)r(s@rrr=sJ(,(* 33%3& 3  3"*77rrcFeZdZejj ddZy)AddSlashHandlercyr rr$s rgetzAddSlashHandler.getw rNrRrS)rUrVrWr=r>addslashr]rrrrZrZvs [[  rrZcFeZdZejj ddZy)RemoveSlashHandlercyr rr\s rr]zRemoveSlashHandler.get}r^rNr_)rUrVrWr=r> removeslashr]rrrrbrb|s [[  rrbc eZdZdZddZddZy)_SpecialRequestHandlerz2Superclass for "special" endpoints, like /healthz.c|jddtr|jddyt|jjj dx}r|jdt d|yy)Nr*r+zAccess-Control-Allow-Origin*Originr)r/rrrequestheadersr]r)r$rs rset_default_headersz*_SpecialRequestHandler.set_default_headerssc 4 * , OO93 ? )=)=)A)A()KKv L OO94v;N OMrcF|jd|jy)a/OPTIONS handler for preflight CORS checks. When a browser is making a CORS request, it may sometimes first send an OPTIONS request, to check whether the server understands the CORS protocol. This is optional, and doesn't happen for every request or in every browser. If an OPTIONS request does get sent, and is not then handled by the server, the browser will fail the underlying request. The proper way to handle this is to send a 204 response ("no content") with the CORS headers attached. (These headers are automatically added to every outgoing response, including OPTIONS responses, via set_default_headers().) See https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request N) set_statusfinishr\s roptionsz_SpecialRequestHandler.optionss"  rNr_)rUrVrW__doc__rlrqrrrrfrfs<Prrfc,eZdZddZddZddZddZy) HealthHandlerc||_y)zInitialize the handler. Parameters ---------- callback : callable A function that returns True if the server is healthy N) _callback)r$callbacks rr#zHealthHandler.initializes "rc@K|jd{y7wr handle_requestr\s rr]zHealthHandler.get!!### c@K|jd{y7wr ryr\s rheadzHealthHandler.headr{r|c@K|jjrAd|jjvr)d|jjvrdnd}t|||jd{\}}|r|j ||j dt rU|jjdi}|j|jjdd |jfi|yy|j d |j |y7w) Nz_stcore/zscript-health-checkz/_stcore/script-health-checkz/_stcore/health)new_pathxsrf_cookie_kwargsxsrf_cookie_name_streamlit_xsrfi) rjurir rvwriteror settingsr] set_cookie xsrf_token)r$rokmsg cookie_kwargss rrzzHealthHandler.handle_requests <<   $,,2B2B B)DLL,<,<</&  -TH E((C JJsO OOC  $ 1 12F K MM%%&8:KLOO$! OOC JJsO+)sA+D-D.B/DN)rwz)Callable[[], Awaitable[tuple[bool, str]]]rRrSr_)rUrVrWr#r]r~rzrrrrtrts "$ $rrt)zhttps://devel.streamlit.testzhttps://*.streamlit.apptestzhttps://*.streamlitapp.testzhttps://*.streamlitapp.comzhttps://share.streamlit.iozhttps://share-demo.streamlit.iozhttps://share-head.streamlit.ioz"https://share-staging.streamlit.iozhttps://*.demo.streamlit.runzhttps://*.head.streamlit.runzhttps://*.staging.streamlit.runzhttps://*.streamlit.runzhttps://*.demo.streamlit.appzhttps://*.head.streamlit.appzhttps://*.staging.streamlit.appzhttps://*.streamlit.appceZdZddZddZy)HostConfigHandlerctj|_tjdr+d|jvr|jj dyyy)Nrzhttp://localhost) _DEFAULT_ALLOWED_MESSAGE_ORIGINScopy_allowed_originsrrappendr\s rr#zHostConfigHandler.initializesT @ E E G   6 7"$*?*??  ! ! ( (); <@ 8rc tK|j|jddddddd|jdyw)NF)allowedOriginsuseExternalAuthTokenenableCustomParentMessagesenforceDownloadInNewTab metricsUrlblockErrorDialogsresourceCrossOriginModer)rrror\s rr]zHostConfigHandler.getsB "&"7"7(-.3+0 %*,0   s68Nr_)rUrVrWr#r]rrrrrs  =rr)rRbool)rrrRr)% __future__rrAretypingrrrr tornado.webr= streamlitrr streamlit.web.server.server_utilr r r collections.abcr rrcompiler-r__annotations__rrr>rRequestHandlerrZrbrfrtrrrrrrs# 22' ==2::=>-?"E> + 67 5567r gkk00  33 W[[77>2*2j$ ..r