o
    i                     @   s  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 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lZd d
lZd dlmZ d dlmZ d d
lZedefddZeedZdgZejeeddgdgd ej ddddd Z!e"e e"e e"e ej#dedddd ej#deddd d ej#d!ed"dd#d$d e d%d&d' Z$e d(d)d* Z%d+d, Z&e&e_'e(d-krd d
l)Z)e)j*ed.d/d0d1 d
S d
S )2    )FastAPIHTTPException)CORSMiddleware)asynccontextmanager)StaticFiles)FileResponse)database_yokohama)router)get_openapi)loggerN)	TokenData)datetimeappc                 C  s8   t  I d H  td d V  t  I d H  td d S )Nstartend)r   connectprint
disconnect)r    r   /home/air/sos_test/back/main.pylifespan   s   r   )r   *T)allow_originsallow_credentialsallow_methodsallow_headers/F)include_in_schemac                      s   dS )NTr   r   r   r   r   index0   s   r   z/reportsz/home/air/sos/templates)	directoryreports)namez/sos_imagesz/home/air/sos/front/image
sos_imagesz/segue/gemini/frontz/home/air/segue/gemini/front)r   htmlstaticz%/segue/gemini/front/add_question.htmlc                     &   d} t j| rt| S tddd)Nz./home/air/segue/gemini/front/add_question.html  File not foundstatus_codedetailospathisfiler   r   	file_pathr   r   r   serve_add_question_fileO   
   r1   z"/segue/gemini/front/show_list.htmlc                     r%   )Nz+/home/air/segue/gemini/front/show_list.htmlr&   r'   r(   r+   r/   r   r   r   serve_show_list_fileW   r2   r3   c                  C   s*   t jrt jS tdddt jd} | t _t jS )NzAIR API with chatgptz1.0.0zy
        Speech To Text Websocket Endpoint : /ws?token=
        Send to voice stream data
        Receive a text
        )titleversiondescriptionroutes)r   openapi_schemar
   r7   )r8   r   r   r   custom_openapi`   s   
r9   __main__z0.0.0.0i"  debug)hostport	log_level)+fastapir   r   fastapi.middleware.corsr   
contextlibr   fastapi.staticfilesr   fastapi.responsesr   dbr   
stt_routerr	   yokohama_routerfind_pdfreport_routerfastapi.openapi.utilsr
   configr   requests	db_moduleschemasr   r   r,   r   r   originsadd_middlewaregetr   include_routermountr1   r3   r9   openapi__name__uvicornrunr   r   r   r   <module>   sr    







