patch
Browse files
app.py
CHANGED
@@ -26,6 +26,8 @@ def download_image_locally(image_url: str, local_path: str = "downloaded_image.p
|
|
26 |
Returns:
|
27 |
str: The filesystem path of the saved file – suitable for returning to a **gr.File** output, or as an MCP tool response.
|
28 |
"""
|
|
|
|
|
29 |
response = requests.get(image_url, timeout=30)
|
30 |
response.raise_for_status()
|
31 |
# If the caller passed only a filename, save into a temporary directory to avoid permission issues
|
@@ -170,7 +172,10 @@ with gr.Blocks(css=css) as demo:
|
|
170 |
|
171 |
with gr.Accordion("Download Image from URL", open=False):
|
172 |
image_url_input = gr.Text(label="Image URL", placeholder="Enter image URL (e.g., http://.../image.png)")
|
173 |
-
filename_input = gr.Text(
|
|
|
|
|
|
|
174 |
download_from_url_btn = gr.Button("Download Image")
|
175 |
downloaded_file_output = gr.File(label="Downloaded File")
|
176 |
|
|
|
26 |
Returns:
|
27 |
str: The filesystem path of the saved file – suitable for returning to a **gr.File** output, or as an MCP tool response.
|
28 |
"""
|
29 |
+
if local_path == "":
|
30 |
+
local_path = "downloaded_image.png"
|
31 |
response = requests.get(image_url, timeout=30)
|
32 |
response.raise_for_status()
|
33 |
# If the caller passed only a filename, save into a temporary directory to avoid permission issues
|
|
|
172 |
|
173 |
with gr.Accordion("Download Image from URL", open=False):
|
174 |
image_url_input = gr.Text(label="Image URL", placeholder="Enter image URL (e.g., http://.../image.png)")
|
175 |
+
filename_input = gr.Text(
|
176 |
+
label="Filename (optional)",
|
177 |
+
placeholder=" Filename",
|
178 |
+
)
|
179 |
download_from_url_btn = gr.Button("Download Image")
|
180 |
downloaded_file_output = gr.File(label="Downloaded File")
|
181 |
|