import requests import gradio as gr import os def fetch_animals(service_key, breed_choice, state): url = 'http://apis.data.go.kr/1543061/abandonmentPublicSrvc/abandonmentPublic' params = { 'serviceKey': service_key, 'kind': breed_choice, 'state': state, 'pageNo': '1', 'numOfRows': '1000', '_type': 'json' } response = requests.get(url, params=params) return response.json() def filter_items(items): return [item for item in items if item['sexCd'] == 'F'] def create_animal(item): return { # "Desertion No": item.get("desertionNo", ""), "Thumbnail": item.get("filename", ""), "Date Found": item["happenDt"], "Place Found": item["happenPlace"], "Breed": item["kindCd"], "Color": item["colorCd"], "Age": item["age"], "Weight": item["weight"], "Notice No": item["noticeNo"], "Notice Start Date": item["noticeSdt"], "Notice End Date": item["noticeEdt"], "Image": item["popfile"], "Status": item["processState"], "Gender": item["sexCd"], "Neutered": item["neuterYn"], "Features": item["specialMark"], "Shelter Name": item["careNm"], "Shelter Phone": item["careTel"], "Shelter Address": item["careAddr"], "Controlling Organization": item["orgNm"], "Responsible Person": item.get("chargeNm", ""), "Contact Number": item["officetel"], "Special Note": item.get("noticeComment", ""), } def generate_html(results): html = "
| Thumbnail | Description |
|---|---|
| "
for key, value in animal.items():
if key == "Image":
value = f"{value}"
if key != "Thumbnail":
html += f"{key}: {value} " html += " |