MCP-clock / app.py
matsuap's picture
Initial setup of the project structure and basic files.
2b46680
raw
history blame
928 Bytes
"""
Gradioを使って現在日時と曜日を返すシンプルなWebアプリ。
ボタンを押すと現在の日時と曜日が表示されます。
"""
import gradio as gr
from datetime import datetime
# 現在日時と曜日を返す関数
def get_current_datetime() -> str:
"""
現在の日時と曜日を「YYYY-MM-DD HH:MM:SS (曜日)」形式の文字列で返す。
Returns:
str: 現在の日時と曜日(例: '2024-06-01 12:34:56 (土)')
"""
now = datetime.now()
weekdays = ['月', '火', '水', '木', '金', '土', '日']
weekday = weekdays[now.weekday()]
return now.strftime(f'%Y-%m-%d %H:%M:%S ({weekday})')
with gr.Blocks() as demo:
gr.Markdown("# 現在日時を取得するアプリ")
output = gr.Textbox(label="現在日時")
btn = gr.Button("現在日時を取得")
btn.click(get_current_datetime, outputs=output)
demo.launch(mcp_server=True)