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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,33 +1,37 @@
1
  import gradio as gr
2
 
3
- # State 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",
7
- "title": "Test"
8
  }
9
  ]
10
 
11
- def test_function(text_input, state_data, other_state):
12
  print("This function will never be called due to SSRF validation error")
13
- return gr.update(), gr.update()
14
 
15
  with gr.Blocks() as demo:
16
- # Multiple inputs including state with problematic URLs
17
  state_with_urls = gr.State(data_with_hf_url)
18
- other_state = gr.State([])
19
 
20
- text_input = gr.Textbox(label="Text Input")
 
 
 
 
 
 
 
21
  button = gr.Button("Click me to trigger SSRF error")
22
- output1 = gr.Textbox()
23
- output2 = gr.Textbox()
24
 
25
  # This will fail with: ValueError: Hostname cas-bridge-direct.xethub.hf.co failed validation
26
- # The key is having MULTIPLE inputs where one contains the problematic URLs
27
  button.click(
28
  test_function,
29
- inputs=[text_input, state_with_urls, other_state], # Multiple inputs with HF URLs causes SSRF error
30
- outputs=[output1, output2]
31
  )
32
 
33
  demo.launch()
 
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",
7
+ "title": "Test LoRA"
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",
23
+ columns=1
24
+ )
25
+
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()