3morrrrr commited on
Commit
92f884b
·
verified ·
1 Parent(s): ba190fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -76,20 +76,34 @@ with gr.Blocks(title="Schedule Processor") as demo:
76
  input_file = gr.File(label="Upload Schedule File", type="filepath")
77
 
78
  output_table = gr.Dataframe(label="Preview", wrap=True)
79
- output_file = gr.File(label="Download Processed File", interactive=False)
80
  btn = gr.Button("Process File")
81
 
 
 
 
82
  def process_and_show(file):
83
  df, out_path = process_file(file)
84
  if out_path:
85
- return df, gr.File.update(value=out_path, visible=True)
86
- return df, gr.File.update(visible=False)
 
87
 
 
 
 
88
  btn.click(
89
  process_and_show,
90
  inputs=input_file,
91
- outputs=[output_table, output_file]
 
 
 
 
 
 
92
  )
93
 
94
  if __name__ == "__main__":
95
- demo.launch(share=True)
 
 
76
  input_file = gr.File(label="Upload Schedule File", type="filepath")
77
 
78
  output_table = gr.Dataframe(label="Preview", wrap=True)
79
+ download_button = gr.Button("Download Processed File", visible=False)
80
  btn = gr.Button("Process File")
81
 
82
+ # State to store processed file path
83
+ temp_file_path = gr.State()
84
+
85
  def process_and_show(file):
86
  df, out_path = process_file(file)
87
  if out_path:
88
+ temp_file_path.set(out_path) # Save file path for download
89
+ return df, gr.update(visible=True)
90
+ return df, gr.update(visible=False)
91
 
92
+ def download_file():
93
+ return temp_file_path.get() # Return the stored file path
94
+
95
  btn.click(
96
  process_and_show,
97
  inputs=input_file,
98
+ outputs=[output_table, download_button]
99
+ )
100
+
101
+ download_button.click(
102
+ download_file,
103
+ inputs=None,
104
+ outputs=gr.File(label="Processed Schedule")
105
  )
106
 
107
  if __name__ == "__main__":
108
+ demo.launch()
109
+