a
    i+                     @   s  d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZ d d	lmZmZmZmZmZmZ d d
lmZ eedddZededZeje	ejddgdgd eej eej eej eej eej eej e ddd Z!ee"# j$d d Z%e%& r^ej'dee(e%dddd ej)r~ej'deej)ddd dS )    N)asynccontextmanagersuppress)Path)FastAPI)CORSMiddleware)StaticFiles)settings)init_dbreset_runtime_state)hihahojoinline_webhookpollsstreamws)scheduler_loop)appc                 C  s   t  I d H  tjrt I d H  t }tt|}d V  |  |	  t
tj |I d H  W d    n1 st0    Y  d S )N)r	   r   Zreset_runtime_state_on_startupr
   asyncioEventcreate_taskr   setcancelr   CancelledError)r   Z
stop_eventtask r   >C:\Users\jasmi\Projects\line-hihaho-voting\backend\app\main.pylifespan   s    r   zLINE hihaho Voting MVP)titler   T*)Zallow_originsZallow_credentialsZallow_methodsZallow_headersz/healthc                   C   s   ddiS )Nstatusokr   r   r   r   r   health/   s    r!      Zfrontendz/ui)	directoryhtmlZui)namez/static)r#   Zstatic)*r   
contextlibr   r   pathlibr   Zfastapir   Zfastapi.middleware.corsr   Zfastapi.staticfilesr   Z
app.configr   Zapp.dbr	   r
   Zapp.routersr   r   r   r   r   r   Zapp.services.poll_schedulerr   r   r   Zadd_middlewareZcors_origins_listZinclude_routerZroutergetr!   __file__resolveparentsZ_uiis_dirZmountstrZ
static_dirr   r   r   r   <module>   sH    


