|
import gradio as gr |
|
import requests |
|
import os |
|
|
|
|
|
download_url="https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg" |
|
response = requests.get("https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg") |
|
file_name = download_url.split("/")[-1] |
|
save_path = os.path.join(os.getcwd(), file_name) |
|
with open(save_path, 'wb') as f: |
|
f.write(response.content) |
|
|
|
|
|
download_url="https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg" |
|
def download_file(download_url): |
|
download_url="https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg" |
|
try: |
|
download_url="https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg" |
|
response = requests.get("https://img.zcool.cn/community/0104c15cd45b49a80121416816f1ec.jpg@1280w_1l_2o_100sh.jpg") |
|
file_name = download_url.split("/")[-1] |
|
save_path = os.path.join(os.getcwd(), file_name) |
|
with open(save_path, 'wb') as f: |
|
f.write(response.content) |
|
return f"File downloaded successfully to {save_path}" |
|
except Exception as e: |
|
return f"Error downloading file: {str(e)}" |
|
|
|
iface = gr.Interface(fn=download_file, inputs=["text"], outputs="text") |
|
iface.launch(share=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|