
    Ri	                        U 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m	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ  ej$                  e      Z ee      j-                         j.                  j.                  j.                  Z ee      j-                         j.                  Zed
z  Zedz  Z eddd      Zdaeed<   ej?                  d      d        Z ejC                         r!ejE                  d e e#e            d       ejI                  de      d        Z%ejI                  d      d        Z&edk(  rddl'Z' e'jP                  dddd        yy)!z FastAPI application entry point.    N)Path)FastAPI)HTMLResponseFileResponse)StaticFiles)PipelineManager)create_router)
WebServicefrontendstaticzCo-location MVP Web APIzXWeb interface for interactive co-location pattern mining with Stage3 preference learningz1.0.0)titledescriptionversionservicestartupc                     K   t         dz  dz  } t        t        |             }t        |      at        t              }t        j                  |       t        j                  d       yw)zInitialize services on startup.configzconfig.yaml)config_pathz$Web service initialized successfullyN)
project_rootr   strr
   r   r	   appinclude_routerloggerinfo)r   managerrouters      :   /home/ubuntu/codebase/yexijia/保研/iCoLoc/src/web/app.pystartup_eventr   "   sY      )M9K#k*:;G !G 7#Fv
KK67s   A'A)z/static)	directory)name/)response_classc                     K   t         dz  } | j                         r2t        | dd      5 }t        |j	                               cddd       S t        d      S # 1 sw Y   yxY ww)zServe the main HTML page.z
index.htmlrzutf-8)encoding)contentNaE  
        <!DOCTYPE html>
        <html>
        <head>
            <title>iCoLoc</title>
            <meta charset="utf-8">
        </head>
        <body>
            <h1>Co-location MVP Web Interface</h1>
            <p>Frontend files not found. Please create frontend/index.html</p>
        </body>
        </html>
        )frontend_direxistsopenr   read)
index_pathfs     r   indexr-   :   s^      ,J*cG41 54  %  	 54s   (A&AA&A#A&z/healthc                     K   dddS w)zHealth check endpoint.okzService is running)statusmessage r2       r   healthr4   Q   s      ';<<s   __main__zweb.app:appz0.0.0.0i@  T)hostportreload))__doc__loggingospathlibr   fastapir   fastapi.responsesr   r   fastapi.staticfilesr   controller.managerr   
web.routerr	   web.servicesr
   	getLogger__name__r   __file__resolveparentr   _web_dirr'   
static_dirr   r   __annotations__on_eventr   r(   mountr   getr-   r4   uvicornrunr2   r3   r   <module>rP      sR   &  	   8 + . $ #			8	$ H~%%'..55<<>!!#***$ 
 
#j   i8 8& IIis:?hIO \* +, = =
 zGKKIDF r3   