Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
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):
|