o
    @Tj	                     @   s  d Z ddlZddl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mZmZmZmZmZmZ dddZedefddZeddedZeje
dgddgdgd ee eej eej eej eej eej eej eej ejdeej ddd ee!" j#j#d Z$e$% rejdee&e$dddd dS dS ) z FastAPI application entry point.    N)asynccontextmanager)Path)FastAPI)CORSMiddleware)StaticFiles)settings)ErrorHandlingMiddleware)adminfacegarmenthealthsegmentationuservtonreturnc                  C   sp   d} t jt j| dt tjgdd t dt j t dt j t dt j t dt j d	S )
z1Configure structured logging for the application.u4   %(asctime)s %(levelname)-8s %(name)s — %(message)sz%Y-%m-%d %H:%M:%ST)levelformatdatefmthandlersforcehttpxhttpcoreinsightfaceonnxruntimeN)	loggingbasicConfigINFOStreamHandlersysstdout	getLoggersetLevelWARNING)
log_format r$   (/home/ubuntu/htdocs/ootd-api/app/main.pysetup_logging   s   r&   appc                 C  sp   t   tt}|dtjtj ttj	}dD ]}|| j
ddd qddlm} |  d V  |d d S )Nz/Starting OOTD POC Server (LLM=%s, Mannequin=%s))faces	originalsghost_mannequinr   r   T)parentsexist_okr   )get_segmentation_servicezShutting down OOTD POC Server)r&   r   r    __name__infor   LLM_PROVIDERMANNEQUIN_MODEr   
UPLOAD_DIRmkdirapp.dependenciesr-   )r'   logger
upload_dirsubr-   r$   r$   r%   lifespan"   s   

r8   zOOTD POC Serverz0.2.0)titleversionr8   z https://three.lgesmartmirror.comT*)allow_originsallow_credentialsallow_methodsallow_headersz/storage)	directorystorage)namefrontend/)r@   html)r   N)'__doc__r   r   
contextlibr   pathlibr   fastapir   fastapi.middleware.corsr   fastapi.staticfilesr   
app.configr   app.middlewarer   app.routersr	   r
   r   r   r   r   r   r&   r8   r'   add_middlewareinclude_routerroutermountr2   __file__resolveparentfrontend_direxistsstrr$   r$   r$   r%   <module>   sP    $

	 