Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
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(
|
12 |
print("This function will never be called due to SSRF validation error")
|
13 |
-
return
|
14 |
|
15 |
with gr.Blocks() as demo:
|
16 |
-
#
|
17 |
state_with_urls = gr.State(data_with_hf_url)
|
18 |
-
other_state = gr.State([])
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
27 |
button.click(
|
28 |
test_function,
|
29 |
-
inputs=[
|
30 |
-
outputs=[
|
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()
|