Spaces:
Running
Running
Commit
·
43ddc04
1
Parent(s):
a8f26e0
app.py
CHANGED
@@ -74,10 +74,11 @@ def create_interface():
|
|
74 |
name_input = gr.Text(label="標案名稱", placeholder="輸入標案名稱")
|
75 |
|
76 |
submit_button = gr.Button("查詢")
|
|
|
77 |
|
78 |
# Output for displaying results
|
79 |
output = gr.HTML(label="查詢結果")
|
80 |
-
|
81 |
|
82 |
# Handle fetch and display
|
83 |
def handle_query(date, category, type_, unit_name, unit_id, job_number, name):
|
@@ -95,9 +96,9 @@ def create_interface():
|
|
95 |
handle_query,
|
96 |
inputs=[date_input, category_dropdown, type_dropdown,
|
97 |
unit_name_input, unit_id_input, job_number_input, name_input],
|
98 |
-
outputs=[output,
|
99 |
)
|
100 |
-
download_button.click(export_csv, inputs=[
|
101 |
|
102 |
demo.launch()
|
103 |
|
|
|
74 |
name_input = gr.Text(label="標案名稱", placeholder="輸入標案名稱")
|
75 |
|
76 |
submit_button = gr.Button("查詢")
|
77 |
+
download_button = gr.Button("導出 CSV")
|
78 |
|
79 |
# Output for displaying results
|
80 |
output = gr.HTML(label="查詢結果")
|
81 |
+
csv_data = gr.State() # Temporary state to store DataFrame
|
82 |
|
83 |
# Handle fetch and display
|
84 |
def handle_query(date, category, type_, unit_name, unit_id, job_number, name):
|
|
|
96 |
handle_query,
|
97 |
inputs=[date_input, category_dropdown, type_dropdown,
|
98 |
unit_name_input, unit_id_input, job_number_input, name_input],
|
99 |
+
outputs=[output, csv_data]
|
100 |
)
|
101 |
+
download_button.click(export_csv, inputs=[csv_data], outputs=gr.File())
|
102 |
|
103 |
demo.launch()
|
104 |
|