mizukiryoya
commited on
Commit
·
04e778b
1
Parent(s):
8a8bd54
gradioにした
Browse files
app.py
CHANGED
|
@@ -1,10 +1,39 @@
|
|
| 1 |
import openpyxl
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import openpyxl
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def create_main_app():
|
| 8 |
+
"""メインアプリケーションを作成"""
|
| 9 |
+
|
| 10 |
+
with gr.Blocks() as app:
|
| 11 |
+
report_ui = CustomApp1()
|
| 12 |
+
report_ui.create_interface()
|
| 13 |
+
|
| 14 |
+
return app
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class CustomApp1:
|
| 18 |
+
def increment(self, number_display):
|
| 19 |
+
theme_dbs = openpyxl.load_workbook("demo_themeDB.xlsx", data_only=True)
|
| 20 |
+
if "パークホームズ成城" in theme_dbs.sheetnames:
|
| 21 |
+
theme_db = theme_dbs["パークホームズ成城"]
|
| 22 |
+
else:
|
| 23 |
+
theme_db = theme_dbs.create_sheet(title="パークホームズ成城")
|
| 24 |
+
theme_db.append(["theme_key", "status", "id"])
|
| 25 |
+
|
| 26 |
+
theme_db.append(("1", "2", "3"))
|
| 27 |
+
theme_dbs.save("demo_themeDB.xlsx")
|
| 28 |
+
return number_display + 1
|
| 29 |
+
|
| 30 |
+
def create_interface(self):
|
| 31 |
+
number_display = gr.Number(value=0, label="カウンター", interactive=False)
|
| 32 |
+
button = gr.Button("増やす")
|
| 33 |
+
# ボタンが押されたら increment() を実行して数値を更新
|
| 34 |
+
button.click(fn=self.increment, inputs=number_display, outputs=number_display)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
app = create_main_app()
|
| 39 |
+
app.launch(server_name="0.0.0.0", server_port=7862, share=False)
|