
wa                 @   s  d  d l  m Z m Z m Z m Z m Z m Z d  d l Z d  d l Z d  d l	 m
 Z
 d  d l Z d  d l m Z e e  Z d Z e j d d d d	 g d
 d    Z e j d d d d	 g d d    Z e j d  d d    Z e d k re j d d d d d d  d S)    )Flaskrender_templateurl_forrequestredirectsessionN)escape)datetimezstop_history.json/methodsPOSTGETc              C   s   t  j d k r t  j j d  }  y t |   a t d  y t t d d  } t	 j
 |  } Wd  QRX| j t  t t d d * } | j d  t	 j | | d d	 Wd  QRXt d
 t t   SWn t d  SYn XWn t d  SYn Xt d  S)Nr   secondsztest int durationmoderwr   indent   z/good/zerror_save.htmlz/errorz
index.html)r   methodZformgetintZduration_intprintopenPATH_HISTORYjsonloadappendseekdumpr   strr   )durationfiledata r#   H/home/pi/Desktop/dev.gyre.ch/Source/adrien.capt/projet/h/servercamsys.pyindex   s$    
r%   z/good/<duration>c             C   s   d |  i } t  d |  S)Ntimez	good.html)r   )r    ZtemplateDatar#   r#   r$   good%   s    r'   z/errorc               C   s
   t  d  S)Nz
error.html)r   r#   r#   r#   r$   error+   s    r(   __main__hostz0.0.0.0portP   debugT)Zflaskr   r   r   r   r   r   requestsr   
markupsafer   r&   r	   __name__Zappr   Zrouter%   r'   r(   runr#   r#   r#   r$   <module>   s   .''