awacke1 commited on
Commit
ca36071
1 Parent(s): a6f9b25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -5,12 +5,16 @@ import os
5
  import urllib
6
 
7
  def download_file(url, local_filename):
8
- with requests.get(url, stream=True) as r:
9
- r.raise_for_status()
10
- with open(local_filename, 'wb') as f:
11
- for chunk in r.iter_content(chunk_size=8192):
12
- f.write(chunk)
13
- return local_filename
 
 
 
 
14
 
15
  def download_html_and_files(url):
16
  html_content = requests.get(url).text
 
5
  import urllib
6
 
7
  def download_file(url, local_filename):
8
+ try:
9
+ with requests.get(url, stream=True) as r:
10
+ r.raise_for_status()
11
+ with open(local_filename, 'wb') as f:
12
+ for chunk in r.iter_content(chunk_size=8192):
13
+ f.write(chunk)
14
+ return local_filename
15
+ except requests.exceptions.HTTPError as err:
16
+ print(f"HTTP error occurred: {err}") # or use logging
17
+
18
 
19
  def download_html_and_files(url):
20
  html_content = requests.get(url).text