Mercurial > repos > jay > gaiac_violin_plot
diff gaiac_pm_data_pulling/gaiac_data_download.py @ 2:2e05a4fbcc24 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit c31ef5726cd1d2659da9aeb956c22fb834b177ff
author | jay |
---|---|
date | Fri, 23 May 2025 17:56:01 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gaiac_pm_data_pulling/gaiac_data_download.py Fri May 23 17:56:01 2025 +0000 @@ -0,0 +1,29 @@ +import requests +import sys + +def download_files_from_server(urls): + """ + Function to download files from a FastAPI server. + + Args: + ip (str): The IP address of the FastAPI server. + file_names (list): List of file names to download. + + Returns: + None + """ + for url in urls: + file_name = url.split('/')[len(url.split('/'))-1] + response = requests.get(url) + if response.status_code == 200: + with open(f"{file_name}", "wb") as f: + f.write(response.content) + print(f"File {file_name} downloaded successfully!") + else: + print(f"Failed to download {file_name}. Status code: {response.status_code}") + +if __name__=="__main__": + + if len(sys.argv) > 1: + files = sys.argv[1].split(',') + download_files_from_server( files) \ No newline at end of file