Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
f335a66
1
Parent(s):
65976ca
Update main.py
Browse files
main.py
CHANGED
@@ -54,14 +54,15 @@ def proxy(url):
|
|
54 |
clean_url = url.replace('proxy/', '')
|
55 |
print('Cleaned URL:', clean_url)
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
65 |
except:
|
66 |
print(f'Redirecting')
|
67 |
return send_file('static/error.png', mimetype='image/png')
|
|
|
54 |
clean_url = url.replace('proxy/', '')
|
55 |
print('Cleaned URL:', clean_url)
|
56 |
|
57 |
+
if '.jpg' in clean_url:
|
58 |
+
req = requests.get(f'{clean_url}', headers=headers, timeout=3)
|
59 |
+
content_type = req.headers['content-type']
|
60 |
+
return Response(req.content, content_type=content_type)
|
61 |
+
else:
|
62 |
+
req = requests.get(f'{clean_url}', headers=headers, stream=True, timeout=10)
|
63 |
+
content_type = req.headers['content-type']
|
64 |
+
return Response(req.iter_content(chunk_size=512), content_type=content_type)
|
65 |
+
|
66 |
except:
|
67 |
print(f'Redirecting')
|
68 |
return send_file('static/error.png', mimetype='image/png')
|