| | import gradio as gr |
| | import requests |
| |
|
| | |
| | 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" |
| | params = { |
| | "serviceKey": api_key, |
| | "perPage": "10", |
| | "page": "1", |
| | |
| | } |
| | response = requests.get(base_url, params=params) |
| | if response.status_code == 200: |
| | data = response.json() |
| | |
| | return data |
| | else: |
| | return "API 호출 실패: " + str(response.status_code) |
| |
|
| | |
| | interface = gr.Interface( |
| | fn=search_postal_code, |
| | inputs=[gr.Textbox(label="도이름"), gr.Textbox(label="시군구이름"), gr.Textbox(label="읍면동이름")], |
| | outputs="json", |
| | title="우편번호 검색 프로그램", |
| | description="도이름, 시군구이름, 읍면동이름을 입력하면 해당 지역의 우편번호를 검색해줍니다." |
| | ) |
| |
|
| | |
| | interface.launch() |