Team Ai
Modelpublic

WalidAlHassan/FastAPI-CRUD-Operations

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
mainTest.cpython-312.pyc20 linesDownload Raw Back to __pycache__
1�

2u�e���3�ddlmZddlmZmZmZmZddlmZddl	m4Z5Gd�de�Zddd	d6�ddd
d7�dddd8�dddd9�dddd10�gZd�Z
d�Ze�Zej!d�d��Zej%dej&��defd��Zej!d�d��Zej!d �d!ed"efd#��Zej1d ej2��d!efd$��Zej7d �d!edefd%��Zy&)'�)�Optional)�FastAPI�status�Response�
HTTPException)�	BaseModel)�	randrangec�6�eZdZUeed<eed<dZeeed<y)�po�title�contentN�rating)�__name__�11__module__�__qualname__�str�__annotations__rr�int���<D:\Download\HawkEyes\FastAPI CRUD Operations\app\mainTest.pyrrs��12
�I��K��F�8�C�=�rrzTitle 1z	Content 1�)rr
�idzTitle 2z	Content 2�zTitle 3z	Content 3�zTitle 4z	Content 4�zTitle 5z	Content 5�c�2�tD]}|d|k(s�|cSy�Nr��db)r�is  r�find_idr#s!��
����T�7�b�=��H�rc�v�tt�D]'\}}|d|k(s�t|�t|�|cSyr)�	enumerater!�print)rr"�ps   r�find_index_postr(s7���"�
����1��T�7�b�=��!�H��!�H��H�	rz/postc��K�dtiS�w)N�Messager rrr�all_podtr+!s�����b�>��s�	��status_code�postc��zK�|j�}tdd�|d<tj|�d|iS�w)Nri �rzNew Post)�dictr	r!�append)r.�	post_dicts  r�13creat_postr3%s8�����	�	��I��q��(�I�d�O��I�I�i���i�14 � �s�9;z
/post/latestsc��DK�ttt�dz15}d|iS�w)Nrr*)r!�len)r.s r�latests_postr6,s"����
�c�"�g�a�i�=�D��t���s� z16/post/{id}r�resc��jK�t|�}|sttjd|�d����d|iS�w)Nz
Post with id z not found.�r-�detail�Post)r#rr�HTTP_404_NOT_FOUND)rr7r.s   r�17post_by_idr=1s;�����2�;�D����(A�(A�M�Z\�Y]�]h�Ji�j�j��D�>��s�13c��K�t|�}|�ttjd���tj|�t
tj��S�w)NzData not found.r9r,)r(rrr<r!r1r�HTTP_204_NO_CONTENT)r�indexs  r�delete_postrA9sE�����B��E��}���(A�(A�?�\�\��I�I�e���� :� :�;�;�s�AAc��K�t|�}|dvrttjd���|j	�}||d<|t18|<dt19|iS�w)NzData not foundr9r�Data)r(rrr<r0r!)rr.r@r2s    r�update_postrDAsW�����B��E���}���(A�(A�JZ�[�[��	�	��I��I�d�O��B�u�I��2�e�9���s�AAN)�typingr�fastapirrrr�pydanticr�randomr	rr!r#r(�app�getr+r.�HTTP_201_CREATEDr3r6rr=�deleter?rA�putrDrrr�<module>rNsY���<�<��������!�4�
��!�4�
��!�4�
��!�4�
��!�4����20��i�������������'�f�5�5��6�!�"�!�7�!������������������������L�V�%?�%?��@�<��<�A�<���������"���r