Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,16 @@ import os
|
|
5 |
import urllib
|
6 |
|
7 |
def download_file(url, local_filename):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
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
|