copy / app.py
seawolf2357's picture
Update app.py
f7f4bea verified
raw
history blame
1.09 kB
import gradio as gr
import requests
def get_lunar_info(year, month, day, time):
# API URL 설정
url = "https://api.example.com/get_lunar_info"
# API에 전달할 데이터 설정
data = {
"year": year,
"month": month,
"day": day,
"time": time
}
# API 호출
response = requests.post(url, json=data)
# API 응답 확인 및 결과 반환
if response.status_code == 200:
return response.json()
else:
return "API 호출에 실패했습니다."
# Gradio 인터페이스 구성
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)
# Gradio 앱 실행
demo.launch()