awacke1 commited on
Commit
2f6d918
1 Parent(s): d647402

Update app.py

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