|
import gradio as gr |
|
import requests |
|
|
|
def get_lunar_info(year, month, day, time): |
|
|
|
url = "https://api.example.com/get_lunar_info" |
|
|
|
|
|
data = { |
|
"year": year, |
|
"month": month, |
|
"day": day, |
|
"time": time |
|
} |
|
|
|
|
|
response = requests.post(url, json=data) |
|
|
|
|
|
if response.status_code == 200: |
|
return response.json() |
|
else: |
|
return "API 호출에 실패했습니다." |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("### 생년월일 및 생시 정보 입력") |
|
year = gr.Textbox(label="생년(예: 1990)") |
|
month = gr.Textbox(label="생월(예: 01)") |
|
day = gr.Textbox(label="생일(예: 31)") |
|
time = gr.Textbox(label="생시(예시: 1030)") |
|
|
|
submit_button = gr.Button("정보 제출") |
|
|
|
result = gr.Textbox(label="결과") |
|
|
|
submit_button.click(fn=get_lunar_info, inputs=[year, month, day, time], outputs=result) |
|
|
|
|
|
demo.launch() |