
    Lfi                        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Zd d
lZ eej,                  ej.                        Z ee      ZdZej4                  j7                  e      s ej8                  e       ej;                  d ee      d       ej=                  e	d        ej>                  ej@                          ejB                  e"      Z#ejI                  d      d        Z%ejI                  d      d        Z&ejI                  d      d        Z'ejI                  de      d        Z(ejS                  d      d        Z*e"dk(  rd d
l+Z+ e+jX                  edd !       y
y
)"    )FastAPIHTTPException)StaticFiles)HTMLResponse)
api_router)custom_middleware)settings)Session)text)get_dbN)titledebuguploadsz/uploads)	directory)namez/api/v1)prefix)level/c                  ,    ddt         j                   iS )NmessagezWelcome to )r	   APP_NAME     8/var/www/html/BankruptcyAI-uat/bankruptcy-ai/src/main.py	read_rootr      s    X%6%6$7899r   z/debug/uploadsc                  l   ddl } d}| j                  j                  |      }||| j                  j                  |      | j                  j                  |      r| j                  j	                  |      nd| j                  j                  |      r | j
                  |      ng  | j                         dS )z)Debug endpoint to check uploads directoryr   Nr   F)
upload_dirabsolute_pathexistsis_directoryfilescurrent_working_directory)ospathabspathr   isdirlistdirgetcwd)r#   r   abs_paths      r   debug_uploadsr*   $   s     Jwwz*H !!''..,57WW^^J5Oj1UZ+-77>>*+EJ'2%.RYY[ r   z/api/pusher-configc                  D    t         j                  t         j                  dS )z(Return Pusher configuration for frontend)keycluster)r	   
PUSHER_KEYPUSHER_CLUSTERr   r   r   get_pusher_configr0   6   s      ""** r   z/test)response_classc                      	 t        dd      5 } | j                         cddd       S # 1 sw Y   yxY w# t        $ r Y yw xY w)zServe test HTML pageztest_upload.htmlrNzC<h1>Test page not found</h1><p>test_upload.html file is missing</p>)openreadFileNotFoundError)fs    r   	test_pager8   ?   sF    U$c* 	a668	 	 	 UTUs"   4 (	4 14 4 	A A startupc                  *    t        t                     } y )N)nextr   )dbs    r   startup_eventr=   I   s    vx.Br   __main__z0.0.0.0i@  )hostport)-fastapir   r   fastapi.staticfilesr   fastapi.responsesr   src.api.v1.routesr   	v1_routersrc.core.middlewarer   src.core.configr	   sqlalchemy.ormr
   
sqlalchemyr   src.database.sessionr   loggingr#   r   DEBUGappr   r$   r   makedirsmountinclude_routerbasicConfigINFO	getLogger__name__loggergetr   r*   r0   r8   on_eventr=   uvicornrunr   r   r   <module>rZ      s{   * + * 5 1 $ "  '  	H%%X^^<  
	ww~~j!BKK
 		*kJ7i	 H   9Y  /   ',, '			8	$ : : 	 " 	  .U /U i! ! zGKK)$/ r   