
    L{h"                        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d            e            Z e            Z e            Z G d d	e          Z G d
 de          Ze                    d          defd            ZdS )    )	APIRouter)API_BaseRequest)API_BaseResponse)EasySQL)EasyUserNzSET AVATAR API ENDPOINTc                       e Zd ZU dZeed<   dS )API_Request 
image_dataN)__name__
__module____qualname__r   str__annotations__     8C:\xampp\htdocs\dev\Site\Backend\api\users\set_avatar.pyr	   r	      s"         Jr   r	   c                       e Zd ZdS )API_ResponseN)r   r   r   r   r   r   r   r      s        Dr   r   z/users/set_avatarrequestc                 *   t                      }| j        }t                              |          }|dk    rd|_        d|_        d|_        |S t          j        | j	                  }d| d}t          |d          5 }|                    |           d d d            n# 1 swxY w Y   t                              |          }||d<   t                              ||          dk    rd|_        d|_        d	|_        |S d
|_        d|_        d|_        |S )NFi  zLogin Failurez../Frontend/images/avatars/z.jpgwbavatari  zInternal Server ErrorT   r
   )r   session_hashuserauthenticate_sessionsuccessstatus_codereasonbase64	b64decoder   openwriteget_attributesset_attributes)r   api_responser   usernameimgdatafilenamefuser_attributess           r   update_avatarr-      s^     >>L'L((66H5$#& -w122G;X;;;H	h		 	               ))(33O (OH8_55>>$#& 5L"LLs   <BB"%B")fastapir   api.core.EasyMessager   r   api.core.EasySQLr   api.core.EasyUserr   r!   jsonprintroutersql_connectionr   r	   r   postr-   r   r   r   <module>r7      s9  
       0 0 0 0 0 0 1 1 1 1 1 1 $ $ $ $ $ $ & & & & & &         	xzz    /   	 	 	 	 	# 	 	 	  !!;    "!  r   