Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
import json
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
{
|
7 |
"image": "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png",
|
8 |
-
"title": "
|
9 |
-
"repo": "Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style",
|
10 |
-
"trigger_word": ", Paper Cutout Style"
|
11 |
}
|
12 |
]
|
13 |
|
14 |
-
def
|
15 |
-
"
|
16 |
-
|
17 |
-
|
18 |
-
if custom_lora:
|
19 |
-
pass
|
20 |
-
|
21 |
-
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices
|
22 |
-
|
23 |
-
# Initialize state with URLs that will cause SSRF validation issues
|
24 |
-
loras_state = gr.State(sample_loras)
|
25 |
|
26 |
with gr.Blocks() as demo:
|
27 |
-
|
28 |
-
|
29 |
-
selected_indices = gr.State([])
|
30 |
-
|
31 |
-
custom_lora_input = gr.Textbox(label="Custom LoRA", placeholder="Enter custom LoRA")
|
32 |
-
|
33 |
-
gallery = gr.Gallery(
|
34 |
-
[(item["image"], item["title"]) for item in sample_loras],
|
35 |
-
label="LoRA Gallery",
|
36 |
-
columns=2
|
37 |
-
)
|
38 |
-
|
39 |
-
broken_button = gr.Button("Add Custom LoRA (Broken - passes state with URLs)")
|
40 |
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
)
|
48 |
|
49 |
-
|
50 |
-
# Set global variable for working version
|
51 |
-
loras = sample_loras
|
52 |
-
demo.launch()
|
|
|
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(state_data):
|
12 |
+
print("This function will never be called due to SSRF validation error")
|
13 |
+
return 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 |
+
button = gr.Button("Click me to trigger SSRF error")
|
20 |
+
output = gr.Textbox()
|
21 |
|
22 |
+
# This will fail with: ValueError: Hostname cas-bridge-direct.xethub.hf.co failed validation
|
23 |
+
button.click(
|
24 |
+
test_function,
|
25 |
+
inputs=[state_with_urls], # Passing state with HF URLs causes SSRF validation error
|
26 |
+
outputs=[output]
|
27 |
)
|
28 |
|
29 |
+
demo.launch()
|
|
|
|
|
|