From 321bdca73bf4a2253c73c73725745c724732cbdc Mon Sep 17 00:00:00 2001 From: RichardHeise <richardfhf5@gmail.com> Date: Wed, 10 Apr 2024 11:19:57 -0300 Subject: [PATCH] Comments --- app/proxy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/proxy.py b/app/proxy.py index 7e30e46..981c4d4 100644 --- a/app/proxy.py +++ b/app/proxy.py @@ -5,6 +5,8 @@ from zipfile import ZipFile app = Flask(__name__) +######################################################################################### + def get_collection_ids(collection_id): url = f"https://api.portalmec.c3sl.ufpr.br/v1/collections/{collection_id}" response = requests.get(url) @@ -16,6 +18,8 @@ def get_collection_ids(collection_id): ids.append(file_data['collectionable']['id']) return ids +######################################################################################### + def download_files(ids): downloaded_files = [] for file_id in ids: @@ -24,6 +28,8 @@ def download_files(ids): downloaded_files.append(filename) return downloaded_files +######################################################################################### + def download_file(url): with requests.get(url, stream=True, verify=False) as r: r.raise_for_status() @@ -38,12 +44,16 @@ def download_file(url): return filename +######################################################################################### + def create_zip(files, collection_id): with ZipFile(f"colecao_{collection_id}.zip", 'w') as zip: for file in files: zip.write(file) os.remove(file) +######################################################################################### + @app.route('/<collection_id>', methods=['GET']) def download_zip(collection_id): try: -- GitLab