GitHub Action commited on
Commit
4744e00
·
1 Parent(s): 7cd8277

🚀 Auto-deploy from GitHub Actions

Browse files
contbk/gra_09_weather/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Weather Controller
2
+ # This module provides weather forecast and temperature conversion functionality
contbk/gra_09_weather/weather.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def weather_forecast(city):
4
+ """
5
+ 簡単な天気予報機能のデモ
6
+ """
7
+ # この関数は実際の天気予報APIの代わりにダミーデータを返します
8
+ weather_data = {
9
+ "Tokyo": "晴れ 25°C",
10
+ "Osaka": "曇り 22°C",
11
+ "Kyoto": "雨 18°C",
12
+ "Hiroshima": "晴れ 27°C",
13
+ "Sapporo": "雪 -2°C"
14
+ }
15
+
16
+ result = weather_data.get(city, f"{city}の天気情報は現在利用できません")
17
+ return f"🌤️ {city}の天気: {result}"
18
+
19
+ def temperature_converter(celsius):
20
+ """
21
+ 摂氏から華氏への変換
22
+ """
23
+ if celsius is None:
24
+ return "温度を入力してください"
25
+
26
+ fahrenheit = (celsius * 9/5) + 32
27
+ return f"{celsius}°C = {fahrenheit:.1f}°F"
28
+
29
+ # AI指示による自動作成テスト: 天気予報インターフェース
30
+ # この名前でないと自動検出されません
31
+ with gr.Blocks(title="天気予報システム") as gradio_interface:
32
+ gr.Markdown("# 🌤️ 天気予報 & 温度変換システム")
33
+ gr.Markdown("このインターフェースは AI指示による自動作成のテストです")
34
+
35
+ with gr.Tab("天気予報"):
36
+ with gr.Row():
37
+ city_input = gr.Textbox(
38
+ label="都市名",
39
+ placeholder="Tokyo, Osaka, Kyoto, Hiroshima, Sapporo",
40
+ value="Tokyo"
41
+ )
42
+ weather_btn = gr.Button("天気を確認", variant="primary")
43
+
44
+ weather_output = gr.Textbox(label="天気予報結果", interactive=False)
45
+
46
+ weather_btn.click(
47
+ fn=weather_forecast,
48
+ inputs=city_input,
49
+ outputs=weather_output
50
+ )
51
+
52
+ with gr.Tab("温度変換"):
53
+ with gr.Row():
54
+ celsius_input = gr.Number(
55
+ label="摂氏温度 (°C)",
56
+ value=25
57
+ )
58
+ convert_btn = gr.Button("華氏に変換", variant="secondary")
59
+
60
+ fahrenheit_output = gr.Textbox(label="華氏温度結果", interactive=False)
61
+
62
+ convert_btn.click(
63
+ fn=temperature_converter,
64
+ inputs=celsius_input,
65
+ outputs=fahrenheit_output
66
+ )
67
+
68
+ # サンプル用の例
69
+ gr.Examples(
70
+ examples=[
71
+ ["Tokyo"],
72
+ ["Osaka"],
73
+ ["Kyoto"],
74
+ ["Hiroshima"],
75
+ ["Sapporo"]
76
+ ],
77
+ inputs=city_input
78
+ )
79
+
80
+ # テスト用のスタンドアロン実行
81
+ if __name__ == "__main__":
82
+ gradio_interface.launch()