multimodalart HF Staff commited on
Commit
72bad37
·
verified ·
1 Parent(s): 8a431c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
 
3
- # Data with HuggingFace URL that redirects to cas-bridge-direct.xethub.hf.co
4
  data_with_hf_url = [
5
  {
6
  "image": "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png",
@@ -8,15 +7,12 @@ data_with_hf_url = [
8
  }
9
  ]
10
 
11
- def test_function(custom_input, state_data, gallery):
12
  print("This function will never be called due to SSRF validation error")
13
- return state_data, gr.update()
14
 
15
  with gr.Blocks() as demo:
16
- # Initialize state with problematic HuggingFace URL
17
- state_with_urls = gr.State(data_with_hf_url)
18
 
19
- # Gallery initialized with the same URLs
20
  gallery = gr.Gallery(
21
  [(item["image"], item["title"]) for item in data_with_hf_url],
22
  label="Gallery with HF URLs",
@@ -26,12 +22,10 @@ with gr.Blocks() as demo:
26
  custom_input = gr.Textbox(label="Custom input")
27
  button = gr.Button("Click me to trigger SSRF error")
28
 
29
- # This will fail with: ValueError: Hostname cas-bridge-direct.xethub.hf.co failed validation
30
- # The key is passing BOTH state_with_urls AND gallery as inputs
31
  button.click(
32
  test_function,
33
- inputs=[custom_input, state_with_urls, gallery], # Both state and gallery with HF URLs
34
- outputs=[state_with_urls, gallery] # Gallery also in outputs
35
  )
36
 
37
  demo.launch()
 
1
  import gradio as gr
2
 
 
3
  data_with_hf_url = [
4
  {
5
  "image": "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png",
 
7
  }
8
  ]
9
 
10
+ def test_function(gallery):
11
  print("This function will never be called due to SSRF validation error")
12
+ return gr.update()
13
 
14
  with gr.Blocks() as demo:
 
 
15
 
 
16
  gallery = gr.Gallery(
17
  [(item["image"], item["title"]) for item in data_with_hf_url],
18
  label="Gallery with HF URLs",
 
22
  custom_input = gr.Textbox(label="Custom input")
23
  button = gr.Button("Click me to trigger SSRF error")
24
 
 
 
25
  button.click(
26
  test_function,
27
+ inputs=[gallery],
28
+ outputs=[gallery]
29
  )
30
 
31
  demo.launch()