kacapower commited on
Commit
fe8f606
·
verified ·
1 Parent(s): 27a87bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -221,9 +221,13 @@ with gr.Blocks() as agent_ui:
221
 
222
  code, preview, words, keywords = generate_blogger_html(app_query, custom_link, mod_features, t_color, t_link, c_size)
223
 
224
- # Unhide the file download component so the user can download the txt file
225
- return code, preview, words, keywords, gr.update(visible=False), gr.update(visible=True), state, gr.update(value="latest_draft.txt", visible=True)
226
-
 
 
 
 
227
  # --- BINDS ---
228
  login_btn.click(fn=verify_login, inputs=[pwd_input, session_state], outputs=[session_state, login_screen, main_app, login_err])
229
 
 
221
 
222
  code, preview, words, keywords = generate_blogger_html(app_query, custom_link, mod_features, t_color, t_link, c_size)
223
 
224
+ # --- THE FIX: Only attempt to serve the file if it exists and there are no errors ---
225
+ if os.path.exists("latest_draft.txt") and not code.startswith("Error"):
226
+ file_update = gr.update(value="latest_draft.txt", visible=True)
227
+ else:
228
+ file_update = gr.update(value=None, visible=False)
229
+
230
+ return code, preview, words, keywords, gr.update(visible=False), gr.update(visible=True), state, file_update
231
  # --- BINDS ---
232
  login_btn.click(fn=verify_login, inputs=[pwd_input, session_state], outputs=[session_state, login_screen, main_app, login_err])
233