
    ȹg#                        d dl mZ d dlmZ d dlmZ d dlZd dlZd dlZ e       Z	dgZ
e	j                  ee
ddgdg       e	j                  d	      d
        Ze	j                  d      d        Ze	j                  d      d        Zd Zy)    )Union)FastAPI)CORSMiddlewareNzhttp://localhost:3000T*)allow_originsallow_credentialsallow_methodsallow_headers/c                  
    ddiS )NHelloWorld r       #/var/www/html/stock-fastapi/main.py	read_rootr      s    Wr   z/options/{datasource}c                 ,    t        j                  |       S )N)datasourcesget_options)
datasources    r   	read_itemr      s    "":..r   z/animalsc                  l   d x} }	 t        j                         j                         }|j                  t	                      |j                         } |j                  xs g D cg c]  }|j                   }}|j                          || dS c c}w # t        $ r}dt        |      dcY d }~S d }~ww xY w)N   )errormessage)headersdata)dbget_dbcursorexecute	get_queryfetchalldescriptionnameclose	Exceptionstr)animals	col_namescurcoles        r   get_animalsr.      s    Gi1iik  "IK ,,.),)>B?#SXX?	?		 "744 @ 1A001s0   AB #B6B B 	B3B.(B3.B3c                       y)Na   select
	animals.id "Animal ID",
	genotypes.genotype "Genotype",
	breeds.breed "Breed",
	tags.tag_no "Tag No."
    from
	animals
	left join genotypes on genotype_id = genotypes.id
	left join breeds on breed_id = breeds.id
	left join tags on tag_id = tags.idr   r   r   r   r"   r"   +   s    	'r   )typingr   fastapir   fastapi.middleware.corsr   r   jsonr   apporiginsadd_middlewaregetr   r   r.   r"   r   r   r   <module>r8      s      2  i    %%     	 !/ "/ 5 5
'r   