Initial setup of the project structure and basic files.
Browse files- app.py +27 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Gradioを使って現在日時と曜日を返すシンプルなWebアプリ。
|
| 3 |
+
ボタンを押すと現在の日時と曜日が表示されます。
|
| 4 |
+
"""
|
| 5 |
+
import gradio as gr
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
|
| 8 |
+
# 現在日時と曜日を返す関数
|
| 9 |
+
def get_current_datetime() -> str:
|
| 10 |
+
"""
|
| 11 |
+
現在の日時と曜日を「YYYY-MM-DD HH:MM:SS (曜日)」形式の文字列で返す。
|
| 12 |
+
|
| 13 |
+
Returns:
|
| 14 |
+
str: 現在の日時と曜日(例: '2024-06-01 12:34:56 (土)')
|
| 15 |
+
"""
|
| 16 |
+
now = datetime.now()
|
| 17 |
+
weekdays = ['月', '火', '水', '木', '金', '土', '日']
|
| 18 |
+
weekday = weekdays[now.weekday()]
|
| 19 |
+
return now.strftime(f'%Y-%m-%d %H:%M:%S ({weekday})')
|
| 20 |
+
|
| 21 |
+
with gr.Blocks() as demo:
|
| 22 |
+
gr.Markdown("# 現在日時を取得するアプリ")
|
| 23 |
+
output = gr.Textbox(label="現在日時")
|
| 24 |
+
btn = gr.Button("現在日時を取得")
|
| 25 |
+
btn.click(get_current_datetime, outputs=output)
|
| 26 |
+
|
| 27 |
+
demo.launch(mcp_server=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
gradio[mcp]
|