File size: 1,296 Bytes
179dfbd
 
 
 
 
 
81e2a23
179dfbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import requests

# API 호출 함수 정의
def search_postal_code(region, city, town):
    base_url = "https://api.odcloud.kr/api/15070405/v1/uddi:dd22ecb1-d970-4d91-af69-97155311dc0a"
    api_key = "/15070405/v1/uddi:dd22ecb1-d970-4d91-af69-97155311dc0a"  # 실제 API 키로 대체해야 함
    params = {
        "serviceKey": api_key,
        "perPage": "10",  # 한 번에 받아올 데이터 수
        "page": "1",  # 페이지 번호
        # 추가적인 필터링이 필요하다면 여기에 파라미터 추가
    }
    response = requests.get(base_url, params=params)
    if response.status_code == 200:
        data = response.json()
        # API 응답에서 우편번호 데이터 추출 로직 구현 필요
        return data
    else:
        return "API 호출 실패: " + str(response.status_code)

# Gradio 인터페이스 정의
interface = gr.Interface(
    fn=search_postal_code,
    inputs=[gr.Textbox(label="도이름"), gr.Textbox(label="시군구이름"), gr.Textbox(label="읍면동이름")],
    outputs="json",
    title="우편번호 검색 프로그램",
    description="도이름, 시군구이름, 읍면동이름을 입력하면 해당 지역의 우편번호를 검색해줍니다."
)

# 애플리케이션 실행
interface.launch()