File: //proc/self/root/lib64/python2.7/Tools/scripts/serve.pyo
�
{�fc           @   s�   d  Z  d d l Z d d l Z d d l Z d d l m Z m Z d �  Z e d k r� e j	 d Z
 e e j	 � d k r� e e j	 d � n d Z
 e j d	 e
 e � Z d
 e
 e
 f GHy e j �  Wq� e k
 r� d GHq� Xn  d S(   s
  
Small wsgiref based web server. Takes a path to serve from and an
optional port number (defaults to 8000), then tries to serve files.
Mime types are guessed from the file names, 404 errors are raised
if the file is not found. Used for the make serve target in Doc.
i����N(   t
   simple_servert   utilc         C   s�   t  j j t |  d d � } d | j t  j j � d k rT t  j j | d � } n  t j | � d } t  j j | � r� | d d | f g � t j	 t
 | � � S| d	 d g � d g Sd  S(
   Nt	   PATH_INFOi   t   .i����s
   index.htmli    s   200 OKs   Content-Types
   404 Not Founds
   text/plains	   not found(   s   Content-Types
   text/plain(   t   ost   patht   joint   splitt   sept	   mimetypest
   guess_typet   existsR   t   FileWrappert   open(   t   environt   respondt   fnt   type(    (    s+   /usr/lib64/python2.7/Tools/scripts/serve.pyt   app
   s    t   __main__i   i   i@  t    s(   Serving %s on port %s, control-C to stops   Shutting down.(   t   __doc__t   sysR   R	   t   wsgirefR    R   R   t   __name__t   argvR   t   lent   intt   portt   make_servert   httpdt
   serve_forevert   KeyboardInterrupt(    (    (    s+   /usr/lib64/python2.7/Tools/scripts/serve.pyt   <module>   s   	
.