o
    xiZ                     @   st  d dl mZmZ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Zd dlmZmZmZ d dlmZ d d	lmZmZ d d
lmZmZ d dlmZmZ edefddZeedZe
ddZejdedddd ejdedddd e ej! e ej! ej"deddd Z#ej"deddefddZ$ej"dedd d! Z%ded"efd#d$Z&ej"d%edeefded"efd&d'Z'ej"d(edeefded"efd)d*Z(ej"d+edeefded"efd,d-Z)ej"d.edeefded"efd/d0Z*ej"d1edeefded"efd2d3Z+ej"d4edeefded"efd5d6Z,ej"d7eddefd8d9Z-dS ):    )FastAPIDependsRequest)HTMLResponseRedirectResponse)StaticFiles)Jinja2Templates)asynccontextmanagerN)Sessionselectfunc)datetime)create_db_and_tablesget_session)resumesauth)ResumeUserappc                 C  s   t   d V  d S )N)r   )r    r   9/var/www/html/Resume-Parser/resume-parser-inhouse/main.pylifespan   s   
r   )r   	templates)	directoryz/staticstatic)namez/uploadsuploads/)response_classc                         t ddS )N/loginurlr   r   r   r   r   	read_root      
r$   r    requestc                       t dd| iS )Nz
login.htmlr&   r   TemplateResponser&   r   r   r   
login_page       r+   z
/dashboardc                      r   )N/dashboard/parserr!   r#   r   r   r   r   dashboard_page$   r%   r.   sessionc                    s   | tttj }| tttj }| tttjtj	dk }| tttjtj
dk }| tttj d }| tttj d }| ||||d||dS )NT   
   )total_resumestotal_usersadmin_usersactive_users)r&   statsrecent_resumesrecent_users)execr   r   countr   idoner   whereis_admin	is_activeorder_by
created_atdesclimitall)r&   r/   r2   r3   r4   r5   r7   r8   r   r   r   get_dashboard_context(   s    &&$$rE   r-   c                       t | |I d H }td|S Nzdashboard.htmlrE   r   r)   r&   r/   ctxr   r   r   dashboard_parser?      rK   z/dashboard/intelligencec                    rF   rG   rH   rI   r   r   r   dashboard_intelligenceD   rL   rM   z/dashboard/usersc                    rF   rG   rH   rI   r   r   r   dashboard_usersI   rL   rN   z/dashboard/passwordc                    rF   rG   rH   rI   r   r   r   dashboard_passwordN   rL   rO   z/dashboard/accountc                    rF   rG   rH   rI   r   r   r   dashboard_accountS   rL   rP   z/dashboard/adminc                    rF   rG   rH   rI   r   r   r   admin_dashboardX   s   rQ   z/dashboard/resume/{resume_id}c                    r'   )Nzresume_detail.htmlr&   r(   r*   r   r   r   resume_detail_page_   r,   rR   ).fastapir   r   r   fastapi.responsesr   r   fastapi.staticfilesr   fastapi.templatingr   
contextlibr	   ossqlmodelr
   r   r   r   databaser   r   routersr   r   modelsr   r   r   r   r   mountinclude_routerroutergetr$   r+   r.   rE   rK   rM   rN   rO   rP   rQ   rR   r   r   r   r   <module>   sP    



