Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
|
|
|
| 3 |
|
| 4 |
def download_file(download_url):
|
| 5 |
try:
|
| 6 |
response = requests.get(download_url)
|
|
|
|
|
|
|
| 7 |
with open(save_path, 'wb') as f:
|
| 8 |
f.write(response.content)
|
| 9 |
-
return f"File downloaded successfully to"
|
| 10 |
except Exception as e:
|
| 11 |
return f"Error downloading file: {str(e)}"
|
| 12 |
|
| 13 |
iface = gr.Interface(fn=download_file, inputs=["text"], outputs="text")
|
| 14 |
iface.launch(share=True)
|
| 15 |
|
|
|
|
| 16 |
# subprocess.run(["wget", "-O", "G_38400.pth", "https://github.com/00000000002/render/releases/download/ddd/G_38400.pth"])
|
| 17 |
|
| 18 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
def download_file(download_url):
|
| 6 |
try:
|
| 7 |
response = requests.get(download_url)
|
| 8 |
+
file_name = download_url.split("/")[-1] # Extracting the file name from the URL
|
| 9 |
+
save_path = os.path.join(os.getcwd(), file_name)
|
| 10 |
with open(save_path, 'wb') as f:
|
| 11 |
f.write(response.content)
|
| 12 |
+
return f"File downloaded successfully to {save_path}"
|
| 13 |
except Exception as e:
|
| 14 |
return f"Error downloading file: {str(e)}"
|
| 15 |
|
| 16 |
iface = gr.Interface(fn=download_file, inputs=["text"], outputs="text")
|
| 17 |
iface.launch(share=True)
|
| 18 |
|
| 19 |
+
|
| 20 |
# subprocess.run(["wget", "-O", "G_38400.pth", "https://github.com/00000000002/render/releases/download/ddd/G_38400.pth"])
|
| 21 |
|
| 22 |
|