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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -77,33 +77,31 @@ with gr.Blocks(title="Schedule Processor") as demo:
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
 
 
 
77
 
78
  output_table = gr.Dataframe(label="Preview", wrap=True)
79
  download_button = gr.Button("Download Processed File", visible=False)
80
+ temp_file_path = gr.State(value=None)
81
  btn = gr.Button("Process File")
82
 
 
 
 
83
  def process_and_show(file):
84
  df, out_path = process_file(file)
85
  if out_path:
86
+ return df, out_path, gr.update(visible=True)
87
+ return df, None, gr.update(visible=False)
 
88
 
89
+ def download_file(out_path):
90
+ return out_path
91
 
92
  btn.click(
93
  process_and_show,
94
  inputs=input_file,
95
+ outputs=[output_table, temp_file_path, download_button]
96
  )
97
 
98
  download_button.click(
99
  download_file,
100
+ inputs=temp_file_path,
101
  outputs=gr.File(label="Processed Schedule")
102
  )
103
 
104
  if __name__ == "__main__":
105
  demo.launch()
106
 
107
+