jomasego commited on
Commit
1ff9b41
·
1 Parent(s): 00e1afd

Fix: Inject JS via gr.Blocks(head=...) for footer text

Browse files
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -276,26 +276,9 @@ demo_interface = gr.Interface(
276
  allow_flagging="never"
277
  )
278
 
279
- # Combine interfaces into a Blocks app
280
- with gr.Blocks() as app:
281
- gr.Markdown("# Contextual Video Data Server")
282
- gr.Markdown("This Hugging Face Space acts as a backend for processing video context for AI models.")
283
-
284
- with gr.Tab("API Endpoint (for AI Models)"):
285
- gr.Markdown("### Use this endpoint from another application (e.g., another Hugging Face Space).")
286
- gr.Markdown("The `process_video_input` function is exposed here.")
287
- api_interface.render()
288
- gr.Markdown("**Note:** Some YouTube videos may fail to download if they require login or cookie authentication due to YouTube's restrictions. Direct video links are generally more reliable for automated processing.")
289
-
290
- with gr.Tab("Demo (for Manual Testing)"):
291
- gr.Markdown("### Manually test video URLs or paths and observe the response.")
292
- demo_interface.render()
293
-
294
- # Launch the Gradio application
295
- if __name__ == "__main__":
296
- # JavaScript to find and replace the 'Use via API' link text
297
- # This attempts to change the text a few times in case Gradio renders elements late.
298
- js_code = """
299
  (function() {
300
  console.log('[MCP Script] Initializing script to change API link text...');
301
  function attemptChangeApiLinkText() {
@@ -342,4 +325,22 @@ if __name__ == "__main__":
342
  }, 100);
343
  })();
344
  """
345
- app.launch(js=js_code, server_name="0.0.0.0")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  allow_flagging="never"
277
  )
278
 
279
+ # JavaScript to find and replace the 'Use via API' link text
280
+ # This attempts to change the text a few times in case Gradio renders elements late.
281
+ js_code_for_head = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  (function() {
283
  console.log('[MCP Script] Initializing script to change API link text...');
284
  function attemptChangeApiLinkText() {
 
325
  }, 100);
326
  })();
327
  """
328
+
329
+ # Combine interfaces into a Blocks app
330
+ with gr.Blocks(head=f"<script>{js_code_for_head}</script>") as app:
331
+ gr.Markdown("# Contextual Video Data Server")
332
+ gr.Markdown("This Hugging Face Space acts as a backend for processing video context for AI models.")
333
+
334
+ with gr.Tab("API Endpoint (for AI Models)"):
335
+ gr.Markdown("### Use this endpoint from another application (e.g., another Hugging Face Space).")
336
+ gr.Markdown("The `process_video_input` function is exposed here.")
337
+ api_interface.render()
338
+ gr.Markdown("**Note:** Some YouTube videos may fail to download if they require login or cookie authentication due to YouTube's restrictions. Direct video links are generally more reliable for automated processing.")
339
+
340
+ with gr.Tab("Demo (for Manual Testing)"):
341
+ gr.Markdown("### Manually test video URLs or paths and observe the response.")
342
+ demo_interface.render()
343
+
344
+ # Launch the Gradio application
345
+ if __name__ == "__main__":
346
+ app.launch(server_name="0.0.0.0")