U
    /e2                     @  sX   d Z ddlmZ ddlZeeZddlmZm	Z	 ddl
mZ dZG dd	 d	eeZdS )
z Provide a Request handler that lists the application (if more than one)
or (if only one) redirects to the route of that applications.

    )annotationsN)RequestHandlerauthenticated   )	AuthMixin)RootHandlerc                   @  s6   e Zd ZdZdd Zedd ZejZej	Z	ej
Z
dS )r   z Implements a custom Tornado handler to display the available applications
    If only one application it redirects to that application route
    c                 O  s,   |d | _ |d | _|d | _|d | _d S )Napplicationsprefixindexuse_redirect)r   r	   r
   r   )selfargskw r   C/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/server/views/root_handler.py
initialize3   s    


zRootHandler.initializec                   s   | j d krdn| j }| jrNt| jdkrNt| j }||d  }| | n.| jd kr\dn| j}| j||t	| j d d S )N r   r   zapp_index.html)r	   items)
r	   r   lenr   listkeysredirectr
   rendersorted)r   r   kwargsr	   Z	app_namesZredirect_tor
   r   r   r   get9   s    zRootHandler.getN)__name__
__module____qualname____doc__r   r   r   r   Zget_login_urlZget_current_userpreparer   r   r   r   r   .   s   
r   )r   
__future__r   logging	getLoggerr   logZtornado.webr   r   Z
auth_mixinr   __all__r   r   r   r   r   <module>   s   
