
    'g                        d Z ddlmZ ddlZddlZddlZddlZddl	m
Z
 ddlmZ ddlmZ ddlmZ d	Zdd
Zej&                  dd       ZdaddZedk(  rddlmZ  edded       yy)z]A small application that can be used to test a WSGI server and check
it for WSGI compliance.
    )annotationsN)wrap)escape   )Request)Responseaz  <!doctype html>
<html lang=en>
<title>WSGI Information</title>
<style type="text/css">
  @import url(https://fonts.googleapis.com/css?family=Ubuntu);

  body       { font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
               'Verdana', sans-serif; background-color: white; color: #000;
               font-size: 15px; text-align: center; }
  div.box    { text-align: left; width: 45em; margin: auto; padding: 50px 0;
               background-color: white; }
  h1, h2     { font-family: 'Ubuntu', 'Lucida Grande', 'Lucida Sans Unicode',
               'Geneva', 'Verdana', sans-serif; font-weight: normal; }
  h1         { margin: 0 0 30px 0; }
  h2         { font-size: 1.4em; margin: 1em 0 0.5em 0; }
  table      { width: 100%%; border-collapse: collapse; border: 1px solid #AFC5C9 }
  table th   { background-color: #AFC1C4; color: white; font-size: 0.72em;
               font-weight: normal; width: 18em; vertical-align: top;
               padding: 0.5em 0 0.1em 0.5em; }
  table td   { border: 1px solid #AFC5C9; padding: 0.1em 0 0.1em 0.5em; }
  code       { font-family: 'Consolas', 'Monaco', 'Bitstream Vera Sans Mono',
               monospace; font-size: 0.7em; }
  ul li      { line-height: 1.5em; }
  ul.path    { font-size: 0.7em; margin: 0 -30px; padding: 8px 30px;
               list-style: none; background: #E8EFF0; }
  ul.path li { line-height: 1.6em; }
  li.virtual { color: #999; text-decoration: underline; }
  li.exp     { background: white; }
</style>
<div class="box">
  <h1>WSGI Information</h1>
  <p>
    This page displays all available information about the WSGI server and
    the underlying Python interpreter.
  <h2 id="python-interpreter">Python Interpreter</h2>
  <table>
    <tr>
      <th>Python Version
      <td>%(python_version)s
    <tr>
      <th>Platform
      <td>%(platform)s [%(os)s]
    <tr>
      <th>API Version
      <td>%(api_version)s
    <tr>
      <th>Byteorder
      <td>%(byteorder)s
    <tr>
      <th>Werkzeug Version
      <td>%(werkzeug_version)s
  </table>
  <h2 id="wsgi-environment">WSGI Environment</h2>
  <table>%(wsgi_env)s</table>
  <h2 id="installed-eggs">Installed Eggs</h2>
  <p>
    The following python packages were installed on the system as
    Python eggs:
  <ul>%(python_eggs)s</ul>
  <h2 id="sys-path">System Path</h2>
  <p>
    The following paths are the current contents of the load path.  The
    following entries are looked up for Python packages.  Note that not
    all items in this path are folders.  Gray and underlined items are
    entries pointing to invalid resources or used by custom import hooks
    such as the zip importer.
  <p>
    Items with a bright background were expanded for display from a relative
    path.  If you encounter such paths in the output you might want to check
    your setup as relative paths are usually problematic in multithreaded
    environments.
  <ul class="path">%(sys_path)s</ul>
</div>
c               #    K   t         j                  dk(  rdd} ndd} t         j                  j                  t        j                               }t
        j                  D ]  }t         j                  j                  ||xs t         j                  j                        } | t         j                  j                  |            t         j                  j                  |       ||k7  f  y w)Nposixc                    t         j                  j                  d      }| j                  |      rd| t	        |      d   } | S )N~)ospath
expanduser
startswithlen)xprefixs     H/var/www/html/knws/venv/lib/python3.12/site-packages/werkzeug/testapp.pystripziter_sys_path.<locals>.stripb   s?    WW'',F||F##f+-()*H    c                    | S N r   s    r   r   ziter_sys_path.<locals>.stripj   s    Hr   )r   strreturnr   )
r   namer   abspathgetcwdsysjoincurdirnormpathisdir)r   cwditemr   s       r   iter_sys_pathr'   _   s     	ww'		 ''//"))+
&C Sww||C!78BGG$$T*+t1D-DddlRRSs   C+C-c                   	 ddl }t        |j                  d       }g }|D ]C  }	 |j                  }|j                  dt        |j                         dt        |       d	       E g }t        | j                  j                         d
       }|D ][  \  }}	dj                  t        t        t        t        |	                              }	|j                  dt        |       d|	 d       ] g }
t!               D ]g  \  }}}g }|r|j                  d       |r|j                  d       |rddj                  |       dnd}|
j                  d| dt        |              i dj                  t        t"        j                        j%                               t        t"        j&                        t        t(        j*                        t"        j,                  t"        j.                  t1               dj                  |      dj                  |      dj                  |
      d	}t3        t4        |z  d      S # t        $ r d}Y )w xY w# t
        t        f$ r d}Y -w xY w)a  Simple test application that dumps the environment.  You can use
    it to check if Werkzeug is working properly:

    .. sourcecode:: pycon

        >>> from werkzeug.serving import run_simple
        >>> from werkzeug.testapp import test_app
        >>> run_simple('localhost', 3000, test_app)
         * Running on http://localhost:3000/

    The application displays important information from the WSGI environment,
    the Python interpreter and the installed libraries.
    r   Nc                6    | j                   j                         S r   )project_namelowerr   s    r   <lambda>ztest_app.<locals>.<lambda>   s    !....0 r   )keyr   unknownz<li>z	 <small>[z	]</small>c                :    t        | d         j                         S )Nr   )reprr+   r   s    r   r,   ztest_app.<locals>.<lambda>   s    tAaDz?O?O?Q r    z<tr><th>z
<td><code>z</code>virtualexpz class=" "z<li>z<br>
)	python_versionplatformr   api_version	byteorderwerkzeug_versionpython_eggswsgi_envsys_pathz	text/html)mimetype)pkg_resourcessortedworking_setImportErrorversion
ValueErrorAttributeErrorappendr   r*   environitemsr!   r   r   r0   r'   r    
splitlinesr9   r   r   r:   r;   _get_werkzeug_versionr   TEMPLATE)reqrA   eggsr=   eggrE   r>   sorted_environr-   valuer?   r&   r2   expandedcss	class_strcontexts                    r   test_apprW   s   s#   
 %%0
 K 
	 kkG 	6#**+,IfWo5FiP	

 HCKK--/5QRN$ J
USU!4567(6#;-z%HIJ H#0? :gxJJy!JJu36hsxx}oQ/B	#i[&,89: !++fS[[&9&D&D&FG3<<(RWWo]]13yy-IIh'IIh'
G Hw&==Y  %"$% N+ 	 G	 s"   H9 I9III I r1   c                 X    t         st        j                  j                  d      a t         S )Nwerkzeug)_werkzeug_version	importlibmetadatarE   r   r   r   rL   rL      s$     %..66zBr   __main__)
run_simple	localhosti  T)use_reloader)r   z"t.Iterator[tuple[str, bool, bool]])rN   r   r   r   )r   r   )__doc__
__future__r   importlib.metadatar[   r   r    typingttextwrapr   
markupsafer   wrappers.requestr   wrappers.responser   rM   r'   applicationrW   rZ   rL   __name__servingr^   r   r   r   <module>rm      s~    #  	 
    % 'JZS( 	<> <>~   z#{D(> r   